UserGuide - Constants

In addition to variables PureBasic provides a method to define constants too. In fact it provides several. We’ll have a quick look at them now. Predefined constants - provided either by PureBasic itself (all begin with #PB_), or from the API for the operating system. The IDE’s Structure Viewer tool has a panel which shows all the predefined constants. User defined constants - by defining a constant name with the prefix # you can provide your own constants to make code more readable.
  #MyConstant1 = 10
  #MyConstant2 = "Hello, World!"
Enumerations – PureBasic will automatically number a series of constants sequentially in an Enumeration, by default enumerations will begin from zero – but this can be altered, if desired.
  Enumeration 10 Step 5
  Debug #MyConstantA   ; will be 0
  Debug #MyConstantB   ; will be 1
  Debug #MyConstantC   ; will be 2
  Debug #MyConstantD   ; will be 10
  Debug #MyConstantE   ; will be 15
  Debug #MyConstantF   ; will be 20

UserGuide Navigation

< Previous: Variables | Overview | Next: Decisions & Conditions >