You are here: PBASIC Language Reference > Compiler Directives

Compiler Directives

BS1 icon BS2 icon BS2e icon BS2sx icon BS2p icon BS2pe icon BS2px icon

 

 

 

 

(Also see Conditional Compilation)

$STAMP

The $STAMP directive is a special command that is included (usually at the top) in a program to indicate the model of BASIC Stamp targeted. Buttons on the editor tool bar simplify adding or modifying the $STAMP directive:

The line below is an example of the $STAMP directive (in this case, it indicates that the program is intended for a BASIC Stamp 2):

' {$STAMP BS2}

This line should be entered into your code, usually near the top, on a line by itself. Note that the directive appears on a comment line (the apostrophe (') indicates this) for compatibility with the DOS versions of the editor.

The 'BS2' in the example above should be changed to indicate the appropriate model of the BASIC Stamp you are using. For example, to use other BASIC Stamp module, enter one (just one) of the following lines into your code:

' {$STAMP BS1}
' {$STAMP BS2}
' {$STAMP BS2e}
' {$STAMP BS2sx}
' {$STAMP BS2p}
' {$STAMP BS2pe}
' {$STAMP BS2px}

The directive itself must be enclosed in brackets, {...}. There should not be any spaces between the dollar sign, $, and the word STAMP, however, the directive may contain additional spaces in certain other areas.

The $STAMP directive is read and acted upon by the BASIC Stamp Windows Editor any time a source code file is loaded, tokenized, downloaded (run) or viewed in the Memory Map.

Defining Multi-File Projects

The BS2e, BS2sx, BS2p and BS2pe modules support multi-file projects, which require a modified syntax for the $STAMP directive. A project is a set of up to eight files that should all be downloaded to the BASIC Stamp for a single application. See Multi-File Projects for details.

Conditional Compilation

To create source code that is usable on multiple BS2 models, but requires changing as set of constants, symbols, or conditions depending on that model, see Conditional Compilation.

$PBASIC

The $PBASIC directive allows the programmer to specify the syntax level for the compiler to use. Buttons on the editor tool bar simplify adding or modifying the $PBASIC directive:

Examples:

' {$PBASIC 1.0} ' use version 1.0 syntax (BS1 only)
' {$PBASIC 2.0} ' use version 2.0 syntax
' {$PBASIC 2.5} ' use version 2.5 syntax

Note that if the $PBASIC directive is omitted, the compiler will assume version 2.0 syntax, unless a $STAMP BS1 directive is present.

$PORT

The purpose of the $PORT directive is to direct a PBASIC program towards a specific serial port. The syntax is as follows:

' {$PORT COM#} 

...where # is a valid port number. When any PBASIC program containing this directive is downloaded, all other ports will be ignored. This directive is especially important if using two of the same BASIC Stamp models (such as two BS2s) on two COM ports and you have two different PBASIC programs to download (one to each BS2). Without this directive, developing and downloading in this case would be a tedious task of always answering the "which Stamp?" prompt. The Port directive can be automatically inserted or modified by selecting the appropriate port from the Directive -> Port menu. The COM ports listed in the Directive -> Port menu are automatically updated any time a change is made to the exiting computer hardware or to the available ports list (in preferences).

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012