Discussion (13)4
Log in or sign up to continue

In Cache uses typeless language. So in some cases such as in command IF
if varName write "true" else  write "false"

or any other logical operations any non zero values will be as true values.

and '1 will give a 0

So set the boolean variable to 0 for false and basically anything else for true?  I'll continue using 1 and 0, thanks!

Not anything else.  True values are any that evaluate numerically as non-zero.  Strings evaluate numerically by treating the beginning of the string as a number until a non-numeric character is encountered.  So "1 avocado" evaluates numerically as 1 and "-.04abc" evaluates numerically as -0.04.  Both of these strings are true.  "basil" is just as false as the null string. 

For more discussion see the docs here:




I think I see, you'd have to do this first though, right?


#Define YES "1"
#Define NO "0"

No, you wouldn't, - if you're inside a class you can just use $$$YES/$$$NO without adding #include or #define:

Class temp.TestTest
  ClassMethod test()
    write $$$YES

And you can use $$$YES and $$$NO inside a class without adding "#include %systemInclude" to it.

I just want to point out that the class thing that folks have been mentioning isn't magical.  It's that RegisteredObject includes %systemInclude and most classes have that in their heirarchy.  I believe that nothing is implicitly included in an Abstract class...

Not exactly nowadays, as I see - %systemInclude is included at %Library.Base level (1 level above the %Library.RegisteredObject).

But idea is the same :)

And even if you don't extend any classes, it any case will be hidden extend with %Library.Base. and %systemInclude still be included.

You cab create a new include file or add the following to one of your existing include files
#define true 1
#define false 0

Then in your class, include this include file and use as follows:
set varName = $$$true