if then bang question Thread last updated on 2006-01-17 16:41:25

Posted by member 124072 on 2006-01-16 18:03:38

this is kind of embaressing but..how would I have an IF THEN execute a !bang command? ive got:
IF opacity = 1 THEN
xpopupAlphaTransparency 255
ENDIF

would I just add another line saying "!execute [!bangcommandgoeshere]"?

Posted by member 212670 on 2006-01-16 20:19:25 link

You need some kind of event to fire a !bang command, or script it.

If you have opacity set to 1 in a themevars, like

opacity 1

and have

IF opacity = 1
xPopupAlphaTransparency 255
ENDIF

in with your popup definitions, then it will be set to 255 when you start LS or recycle. No need for a !bang in that situation.

You could also do

IF opacity = 1
xPopupAlphaTransparency 255
ELSEIF opacity = 2
xPopupAlphaTransparency othernumber
ENDIF

and so on.

Posted by member 124072 on 2006-01-16 20:36:01 link

i know the popup doesnt need a !bang, but ive made a bang with mzscript to set the opacity of labels, so i need the bang to execute at the same time.

Posted by member 1 on 2006-01-16 20:38:48 link

uhmmm...IF's are covered in the docs. You can either read the mzscript or LS docs. Don't be so damn lazy!

Posted by member 124072 on 2006-01-16 20:53:57 link

mzscript uses its own set of bangs to use if's, and im looking at lsdocs.shellfront.org right now, and i dont see anything about how to execute a bang command inside of an IF...

Posted by member 212670 on 2006-01-16 21:12:03 link

That's because you can't, other than something like:

IF whatever = #
LabelOnLeftClick !thisbang
ELSE
LabelOnLeftClick !thatbang
ENDIF

Even then, that's only read on a !recycle (or a !reload).

Bangs need an event to fire (or some scripting setup).

The easiest way to do what you want is to have some var in a themevars, representing the amount of opacity, and having the label use the var for recycles.

Like in a themevar.rc:

trans 255

Label Definition:

LabelAlphaTransparency $trans$

A popup bang example:

*Popup "Set to 150" !execute [!xTextReplace @the file@ @trans *@ @trans 150@][!LabelSetAlpha thelabel 150]

If you want to see some live examples, using a slider, check out my RGB theme, and scroll down to the "Transparency" section of the script.rc.

(Btw, I think the new test builds are changing this to work the way you want.)

Posted by member 1 on 2006-01-16 23:28:03 link

Stalefist :: LINK

bottom of the page

Posted by member 31 on 2006-01-17 05:28:51 link

If you're using 0.24.7 read the release_notes.txt Usage/Help section for correct syntax. Although very similiar to 0.24.6 syntax, there are some differences.

Posted by member 124072 on 2006-01-17 08:52:03 link

dev, i already looked at that, theres nothing there that says how to execute a bang command within an IF, it only shows examples using popup and wallpapers. im trying to do

IF var = 1 THEN
!bang
ENDIF

xcal- i used your idea and now instead of defined numbers for the opacity im using a var, but the only problem is that when i add a *script start !opacitybang line and recycle, i think its running the bang before it actually creates the labels, so it isnt effecting the labels on a recycle. i know the bangs work however because when executed from the popup menu, they do what i want them to do.
anyways, thanks for the help and farewell (i get the feeling im getting on the bad side of dev)

Posted by member 37809 on 2006-01-17 10:09:28 link

If a module B depends on a module A, load A before B.

Posted by member 124072 on 2006-01-17 11:09:49 link

i should get shunned from the forums for this (more so than i already am) i was loading mzscript before label. all i had to do was flop them around.

Posted by member 1 on 2006-01-17 16:41:25 link

Stalefist :: Your IF example is only parsed on startup so defining it for a !Bang would be silly. You are better off using the !ifeval stuff from mzscript if you are looking at working on a toggle bang.