StringExpressionIsTrue
Function StringExpressionIsTrue(expression: String) : Boolean
Returns the result of the condition as a Boolean.
This function evaluates an expression such as "[name] = Bob" where name would be a VirtualVariable, and returns the result of the comparason.
You can also use ParserConstants, ParserMacroExpressions and ParserShortcuts.
Example:
Program
Uses basilisk, pure2d
Begin
InitBasilisk(TRUE)
OpenScreen(640,480,32,FALSE,COB_SHOWCLOSE+COB_SHOWBORDER)
VirtualInteger("apples",4)
VirtualInteger("oranges",7)
VirtualInteger("mangos",2)
VirtualString("name","Bob")
VirtualBoolean("male",TRUE)
VirtualBoolean("female",FALSE)
If IntegerExpressionIsTrue("apples > oranges") then Text(10,10,"I have more apples than oranges")
If IntegerExpressionIsTrue("apples < oranges") then Text(10,10,"I have less apples than oranges")
If IntegerExpressionIsTrue("apples = oranges") then Text(10,10,"I have as many apples as oranges")
If IntegerExpressionIsTrue("apples ! mangos") then Text(10,30,"I have different quantities of mangos and apples")
If IntegerExpressionIsTrue("mangos < 3") then Text(10,50,"I have less than 3 mangos")
If StringExpressionIsTrue("[name] = Bob") then Text(10,70,"My name is Bob")
If StringExpressionIsTrue("[name]! Bob") then Text(10,70,"My name isn't Bob!")
If BooleanExpressionIsTrue("male") then Text(10,90,"I am male.")
If BooleanExpressionIsTrue("male = (NOT female)") then Text(10,110,"I am not female.")
While Not ExitRequested
Flip
Pause(2)
Wend
End