Variable data cannot be stored in a constant. If the number needs to be changed, it may be changed in only one place in the program where the constant is defined. It can be more convenient to use a constant name instead of a constant number. Named constants may be created in a similar manner to variables. Byte- and word-sized arrays are only limited in length by the amount of memory.) The compiler will assure that arrays will fit in memory before successfully compiling. (Arrays may span banks on 18Cxxx devices. They may not span RAM banks on 14-bit or 17Cxxx devices. See the section on memory allocation for more information.Īrrays must fit entirely within one RAM bank on most PICmicros. In the fish array defined above, the elements are numbered fish to fish yielding 8 elements in total.īecause of the way arrays are allocated in memory, there are size limits for each type: Number of elements is how many array locations is desired. Label is any identifier, excluding keywords, as described above. Variable arrays can be created in a similar manner to variables. The variable modifiers may also be used as part of variables in a statement: fido var dog ' fido is another name for dogī0 var w0.byte0 ' b0 is the first byte of word w0ī1 var w0.byte1 ' b1 is the second byte of word w0 This is most useful for accessing the innards of a variable. VAR can also be used to create an alias (another name) for a variable. It may also create additional temporary variables for use in sorting out complex equations. PBP reserves approximately 24 RAM locations for its own use. The number of variables available depends on the amount of RAM on a particular device and the size of the variables and arrays. However, instead of using these "canned" files, we recommend you create your own variables using names that are meaningful to you. These files contain numerous VAR statements that create all of the BASIC Stamp variables and pin definitions. For compatibility sake, two files have been provided that create the standard variables used with the BASIC Stamps: A bs1defs.bas and A bs2defs.bas. There are no predefined user variables in PICBASIC PRO™. Some examples of creating variable are: dog var byte Optional Modifiers add additional control over how the variable is created.
The format for creating a variable is as follows: Label VAR Size Space for each variable is automatically allocated in the microcontroller = s RAM by Variables are where temporary data is stored in a PICBASIC PRO™ program. Rather, any PBP line may start with a line label, which is simply an identifier followed by a colon ( : ). Unlike many older BASICs, PBP doesn't allow line numbers and doesn't require that each line be labeled. In order to mark statements that the program might wish to reference with GOTO or GOSUB commands, PBP uses line labels.
And while labels might be any number of characters in length, PBP only recognizes the first Identifiers are not case sensitive, thus label, LABEL, and Label are all treated as equivalent. An identifier is any sequence of letters, digits, and underscores, although it must not start with a digit. Identifiers are used in PBP for line labels and variable names.