How do I set a boolean?

Answers

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:

http://docs.intersystems.com/cache20152/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_types#GCOS_types_booleans

and

http://docs.intersystems.com/cache20152/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_types#GCOS_types_nonnumasnum

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

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

Comments

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!

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.