custom toggles? Thread last updated on 2006-01-14 13:18:52

Posted by member 124072 on 2006-01-11 16:09:16

ive been pondering on how to make a custom toggle button for a show/hide. so far ive gotten mzscript to define all the label hide/shows to custom !bang commands, and ive got
IF amp = 0 THEN
*mkey all Ctrl Insert !showamp
ENDIF

IF amp = 1 THEN
*mkey all Ctrl Insert !hideamp
ENDIF

im using multikeys-3.1 since other hotkey mods got kinda messed up when i was trying to bind the keypad, but anywho. im also doing
;amphide
*Script bang !hideamp
*Script exec !TextReplace "$ConfigDir$themevars.rc" "amp.*" amp 0"
*Script exec !execute [!labelhide lsxclip] [!labelhide lsxclip2] [!labelhide topbar] [!labelhide topbar3] [!labelhide topbar1]
*Script ~bang

;ampshow
*Script bang !showamp
*Script exec !TextReplace "$ConfigDir$themevars.rc" "amp.*" amp 1"
*Script exec !execute [!labelshow lsxclip] [!labelhide lsxclip2] [!labelshow topbar] [!labelhide topbar3] [!labelshow topbar1]
*Script ~bang

im pretty sure i messed up the textreplace bang and i know a refresh in there would make it load the new variable, but is there a mod that can make a hotkey with 2 different binds to it defined by an IF THEN?

Posted by member 248213 on 2006-01-11 16:48:54 link

make 1 bang with an IF THEN inside it ;) you can even just use mz's var saving stuff I think.

Posted by member 124072 on 2006-01-11 17:15:06 link

good idea. what would i do without you people (probably get drunk in a rage and sleep it off :P)

Posted by member 248213 on 2006-01-11 17:57:25 link

Grow a Brain? :p

Posted by member 124072 on 2006-01-11 18:05:24 link

im still baffled at this whole !ifeq and !ifexist. heres what i got so far. (and it doesnt work.)
;amptoggle
*Script bang !amptoggle
*Script bang !ifExist "amp 1" execute [!xTextReplace @$ConfigDir$themevars.rc@ @amp 1@ @amp 0@][!labelhide lsxclip] [!labelhide lsxclip2] [!labelhide topbar] [!labelhide topbar3] [!labelhide topbar1]
*Script bang !ifExist "amp 0" execute [!xTextReplace @$ConfigDir$themevars.rc@ @amp 0@ @amp 1@][!labelshow lsxclip] [!labelhide lsxclip2] [!labelshow topbar] [!labelhide topbar3] [!labelshow topbar1]
*Script bang exec !Refresh
*Script ~bang

thats whats in the script rc file, and ive got
*mzScriptFile "$ConfigDir$hideconfig.rc"
in the theme.rc file.
im using mzscript-0.8.6l because the new one makes even more less sense to me than this one (i love my grammar)

Posted by member 212670 on 2006-01-11 20:55:52 link

Basic toggle script:

*Script bang !toggle
*Script exec !IfEval ("%{\1}" = "1") '!do_something_if_1' else '!do_something_if_0'
*Script exec !IfEval ("%{\1}" = "1") '!varset %{\1} 0' else '!varset %{\1} 1'
*Script ~bang


The same thing again, but setup differently:
*Script bang !toggle
*Script gotoif ("%{\1}" = "1") off
*Script exec !do_something_if_0
*Script exec !varset %{\1} 1
*Script exit
*Script label off
*Script exec !do_something_if_1
*Script exec !varset %{\1} 0
*Script ~bang


Both are called with "!toggle yourvarhere" like: !toggle amp

If you don't want to use arguments, you can just use !toggle, but you have to change the %{\1} entries in the evaluation parts to an exact var, like "%{amp}". The !varset parts would just be amp (no "%{}").

If you have a series of things to do, I prefer the gotoif setup.

(Note: This is for mzscript-0.9.13. If you're using mzscript-1.0-rc2, the syntax is slightly different, but same idea.)

Posted by member 124072 on 2006-01-12 10:02:02 link

im still lost. ive got
*Script bang !amptoggle
*Script !ifExist (amp 1) '!ampoff'
*Script !ifExist (amp 0) '!ampon'
*Script ~bang

only problem with this is that it runs it though, sees amp 1, so it executes !ampoff, but part of ampoff is to set amp 1 to amp 0, so then it executes !ampon, which sets it back to 1. so basically its turning it off then on again. is there a way to stop the script if it meets 1 line? i know an if else would seem to work logically, but when i tryed
*Script bang !amptoggle
*Script !ifExist (amp 1) '!ampoff' else '!ampon'
*Script ~bang

it didnt work, and im pretty sure it still executed !ampoff regardless of amp being set to 0.
and id rather stay away from the vars, theyre too...much for my small mind to handle.

Posted by member 212670 on 2006-01-12 14:13:42 link

*Script bang !amptoggle
*Script exec !IfEval ("%{amp}" = "1") '!ampoff' else '!ampon'
*Script exec !IfEval ("%{amp}" = "1") '!varset amp 0' else '!varset amp 1'
*Script exec !varsave amp
*Script ~bang

note: !varsave amp may not be necessary if you're autosaving. The !varset stuff could, of course, be moved to the appropriate !ampon/!ampoff script entries, if you wanted.

If you can't get it from here... I can't explain it any better. =)

(mzscript-0.9.13 - syntax may vary)

Posted by member 124072 on 2006-01-12 19:06:13 link

just wondering what the
*Script exec !IfEval ("%{amp}" = "1") '!varset amp 0' else '!varset amp 1'
is for, is it for setting amp to 1 when this is ran?

Posted by member 212670 on 2006-01-12 19:53:56 link

It toggles back and forth. If amp is 1, it changes it to 0. If amp is 0, it changes it to 1.

Basically:
if amp is 1 'do this if it is' else 'do this if it isn't'

Posted by member 124072 on 2006-01-14 13:18:52 link

I HAVE CONQUORED THE BEAST (with help from xcal) :D