QVAL

From SphereWiki
Revision as of 17:32, 26 March 2013 by Mordaunt (talk | contribs) (Created page with "QVAL is used to test if an arguement is true or false in a single line of code. <QVAL <EVAL <LOCAL.A>+1> < <LOCAL.B>? SYSMESSAGE LOCAL.A IS SMALLER:SYSMESSAGE LOCAL.B IS S...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

QVAL is used to test if an arguement is true or false in a single line of code.

<QVAL <EVAL <LOCAL.A>+1> < <LOCAL.B>? SYSMESSAGE LOCAL.A IS SMALLER:SYSMESSAGE LOCAL.B IS SMALLER>

In the above statement is we say that local.a = 3 and local.b = 5

Then local.a+1 = 4

4 being less that 5 means that the argument will return as true and so the first output in the true:false condition will be given

If local.a = 5 and local.b = 5

Then local.a+1 = 6

In these circumstances the argument will return as false and so the condition after : being the false output will be given.

The argument does not have to be greater than or less than, it can also be equal to or even if a specific indicator such as a tag or defname just exists.


Your argument must always be ended with a ?

Must always have 2 possible outputs TRUE:FALSE

And is closed with a >


Be careful if the true:false conditions also require you to use "greater than" It is easy to inadvertently close an argument too soon with a misplaced > after the ? or : in a QVAL argument.



QVAL(test1,test2,res1,res2,res3) in addition to current <QVAL?:> variant. It is useful if dealing with numbers without many IF-s. Sample <eval qval(<VAR.X>,<VAR.Y>,<VAR.ONE>,<VAR.TWO>,<VAR.THREE>)> will return <VAR.ONE> if <VAR.X> < <VAR.Y>, <VAR.TWO> if they are equal, and <VAR.THREE> if the it is greater. If some of the arguments are omited like qval(1,2,,3) it will default to zero