Another Example

Here's a less simple settings/script document showing the use of if/else statements:

# settings.txt

: MODE = (STRICT, TRUE)

$ win_apptitle = Conditionals Example
! win_width = 640
! win_height = 480
! win_depth = 32
? win_mode = CONST_WIN_WINDOWED
! win_flags = CONST_WIN_SHOWBORDER + CONST_WIN_SHOWMINIMIZE + CONST_WIN_SHOWCLOSE

$ about = I don't know what mode you are using!
? checkMode = TRUE


? If (checkMode)

  ? If (win_mode = CONST_WIN_WINDOWED)

     $ about = You are using windowed mode at depth [win_depth]!

  ? Endif


  ? If (win_mode = CONST_WIN_FULLSCREEN)

     $ about = You are using fullscreen mode at depth [win_depth]!

  ? Endif

? Endif



# Don't need this anymore.
: FREE = (checkMode)

And here's a program that reads it:

Program
  Uses
pure2d, basilisk, keyset

Begin
   InitBasilisk(TRUE)

   ReadSettings("example.txt")
   SetAppName(VirtualString("win_apptitle"))   
   OpenScreen(VirtualInteger("win_width"),VirtualInteger("win_height"),VirtualInteger("win_depth"),VirtualBoolean("win_mode"),VirtualInteger("win_flags"))
   FreeVirtualVariablesPrefixed("win_")
   
   Text(10,10,VirtualString("about"))
   
   While Not ExitRequested
       Flip
       Pause
(1)
       If (KeyHits(VK_ESCAPE) > 0) then RequestExit
   Wend
  
End