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, these all begin #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
    #MyConstantA
    #MyConstantB
    #MyConstantC
  EndEnumeration
  
  Enumeration 10 Step 5
    #MyConstantD ; will be 10
    #MyConstantE ; will be 15
    #MyConstantF ; will be 20
  EndEnumeration

UserGuide Navigation

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