Announcement

Collapse
No announcement yet.

Defining Constants

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Defining Constants

    Please add your comments and suggestions as a Reply to this thread.





    PB/WIN - Defining Constants
    PB/Win constants (also known as equates) are defined by prefixing the name of the constant with a "%" character. MSBASIC and VB define constants with the CONST keyword. The MSBASIC/VB compiler then does type conversions at the point of use, if the constant's type was not specified. That overhead does not happen (and is not necessary) with PB/Win. String equates are specified with a leading "$" character.

    However, the MACRO facilities in PB/Win offer a way to retain the CONST syntax in your code, while maintaining the low overhead advantage of PowerBASIC. For example:

    Code:
    MACRO CONST = MACRO
    [statements]
    CONST Something = 1&
    CONST Something_Else = 2???
    CONST AppTitle = "My Application"
    [statements]
    MSGBOX FORMAT$(Something), ,AppTitle
    During compilation, the CONST keyword is replaced by the MACRO word, which dynamically creates a new macro that, in turn, defines a constant.
    See Also
    Last edited by Gary Beene; 28 Oct 2014, 07:17 PM.
Working...
X