VirtualBoolean

Function VirtualBoolean(varname: string, [createval: Boolean=FALSE], [group:Integer=0]) : Boolean
Returns the value of the VirtualBoolean with name varname.

(For how to use groups, see the advanced topic VirtualVariable Groups)

If a VirtualVariable doesn't exist with that name, a new one is created (in the specified group) with the value of createval. This means that you can add the VirtualVariables to your program with sane default values so that you don't have to define so many settings in script files, but you leave the option there if the settings are needed. This might be useful if you pack all media into one exe but the exe saves its settings after it is run.

Here is an example of a settings file:

# settings.txt
# This is a comment

# Here we define booleans (notice the question mark means boolean):
? option1 = TRUE
? option2 = FALSE
? both = option1 AND option2

Here is how it would work in a program:

Program
  Uses
pure2d, basilisk
  
Begin
  InitBasilisk(TRUE)
  ReadSettings("settings.txt")
  OpenScreen(640,480,32,FALSE, COB_SHOWBORDER+COB_SHOWCLOSE)

   If VirtualBoolean("option1") Then MessageBox("option1 is set!")
   If VirtualBoolean("option2") Then MessageBox("option2 is set!")
   If VirtualBoolean("both") Then MessageBox("both options are set!")
  
End

VirtualBooleans can be created either by calling VirtualBoolean on a variable that doesn't exist, using the function ReadSettings or the function MapVirtualBoolean.