Defining String (problem)
Boris
Posts: 81
A simple problem, its gota be something obvious.
How come I get an error when i do this:
Faults VAR Byte(23)
Faults="test"·
Basic Stamp Editor 2.1 stops on letter "e" in "test" and says "Expected ':' or end of line"
do i have to write characters into "Faults" variable one by one?
·
How come I get an error when i do this:
Faults VAR Byte(23)
Faults="test"·
Basic Stamp Editor 2.1 stops on letter "e" in "test" and says "Expected ':' or end of line"
do i have to write characters into "Faults" variable one by one?
·
Comments
Faults = STR "test" ?
Displaying Strings (Byte Arrays)
If you have a string of characters to display (a byte array), you can use the STR formatter to do so. The STR formatter has two forms (as shown in the table above) for variable-width and fixed-width data. The example below is the variable-width form.
alpha VAR Byte(5)
Init:
alpha(0) = "A"
alpha(1) = "B"
alpha(2) = "C"
alpha(3) = "D"
alpha(4) = 0
Main:
DEBUG STR alpha, CR ' display "ABCD"
END
This code displays "ABCD" on the screen. In this form, the STR formatter displays each character contained in the byte array until it finds a character that is equal to 0 (value 0, not "0"). This is convenient for use with the SERIN command's STR formatter, which appends 0's to the end of variable-width character string inputs. NOTE: If your byte array doesn't end with 0, the BASIC Stamp will read and output all RAM register contents until it finds a 0 or until it cycles through all RAM locations.
To specify a fixed-width format for the STR formatter, use the form STR alpha\n; where alpha is the byte array and n is the number of characters to print. Changing the DEBUG line in the example above to: DEBUG STR alpha\2 would display "AB" on the screen.
Msg DATA "BASIC Stamp by Parallax", 0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA