34 lines
1.8 KiB
Plaintext
34 lines
1.8 KiB
Plaintext
REM BBC BASIC (for Windows) has the following scalar variable types;
|
|
REM the type is explicitly indicated by means of a suffix character.
|
|
REM Variable names must start with A-Z, a-z, _ or `, and may contain
|
|
REM any of those characters plus 0-9 and @; they are case-sensitive.
|
|
|
|
A& = 123 : REM Unsigned 8-bit byte (0 to 255)
|
|
A% = 12345678 : REM Signed 32-bit integer (-2147483648 to +2147483647)
|
|
A = 123.45E6 : REM Variant 40-bit float or 32-bit integer (no suffix)
|
|
A# = 123.45E6 : REM Variant 64-bit double or 32-bit integer
|
|
A$ = "Abcdef" : REM String (0 to 65535 bytes)
|
|
|
|
REM Scalar variables do not need to be declared but must be initialised
|
|
REM before being read, otherwise a 'No such variable' error is reported
|
|
REM The static integer variables A% to Z% are permanently defined.
|
|
|
|
REM BBC BASIC also has indirection operators which allow variable-like
|
|
REM entities to be created in memory:
|
|
|
|
DIM addr 7 : REM Allocate 8 bytes of heap
|
|
?addr = 123 : REM Unsigned 8-bit byte (0 to 255)
|
|
!addr = 12345 : REM Signed 32-bit integer (-2147483648 to +2147483647)
|
|
|addr = 12.34 : REM Variant 40-bit or 64-bit float or 32-bit integer
|
|
$addr = "Abc" : REM String terminated by CR (0 to 65535 bytes)
|
|
$$addr = "Abc": REM String terminated by NUL (0 to 65535 bytes)
|
|
|
|
REM The integer indirection operators may be used in a dyadic form:
|
|
offset = 4
|
|
addr?offset = 12345678 : REM Unsigned 8-bit byte at addr+offset
|
|
addr!offset = 12345678 : REM Signed 32-bit integer at addr+offset
|
|
|
|
REM All variables in BBC BASIC have global scope unless they are used
|
|
REM as a formal parameter of a function or procedure, or are declared
|
|
REM as LOCAL or PRIVATE. This is different from most other BASICs.
|