RosettaCodeData/Task/Variables/Commodore-BASIC/variables-3.basic

31 lines
958 B
Plaintext

REM Tiny Basic has exactly 26 variables.
REM They start off initialised to zero.
PRINT A
REM The only data type is sixteen-bit signed integer.
REM They are assigned using the LET statement.
REM Their scope is the whole program.
LET B = -12345
REM The integer arithmetic operations of + - * and / can be used
REM and so can the unary negative and positive operators - +
LET C = 1 + B - B/5
LET A = -B
PRINT "B is ", B
PRINT "C is ", C
GOSUB 10
REM The comparison operators = < > <= >= <> are available,
REM but their results are not expressions and can only be used in an
REM if statement.
LET D = 3
IF D <> 7 THEN LET D = 7
GOTO D-2
PRINT "Skip this"
5 PRINT "Gotos and gosubs can be computed. Beware of moving spaghetti."
END
10 PRINT "B is now ", B
RETURN
REM Tiny Basic does not support arrays or pointers. Strings can
REM be used, but only as string constants within a PRINT statement.