Pascal

Pascalated BASIC

Structured BASIC for the ZX Spectrum

Note

REPEAT
...
UNTIL condition;

REPEAT variable
...
UNTIL condition;

FOR i = 0 TO 0.5 STEP 0
...
LET i = condition
NEXT i

REPEAT
(the variable name can have only 1 character)
(warning: the variable cannot be used at the same time on another cycle)

WHILE condition DO
BEGIN
...
END

WHILE condition DO variable
...
ENDWHILE

FOR i = NOT( condition ) TO 0.5 STEP 0
...
LET i = NOT ( condition )
NEXT i

WHILE
("BEGIN" is not necessary)

IF condition1 THEN
BEGIN
...
END
ELSE IF condition2 THEN
BEGIN
...
END
ELSE
BEGIN
...
END

IF condition1 BEGIN variable
...
ELSEIF condition2
...
ELSE
...
ENDIF

LET i = condition1 : REM IFBEGIN
FOR i = i TO 0.5 STEP 1 : REM IFBEGIN
...
NEXT i : REM ENDIF
LET i = (i<0)*1 + (i=0)*( condition2 ) : REM ELSEIF
FOR i=i TO 0.5 STEP 2 : REM ELSEIF
...
NEXT i : REM ENDIF
LET i = (i=0) : REM ELSE
FOR i = i TO 0.5 STEP 2 : REM ELSE
...
NEXT i : REM ENDIF

IF ... BEGIN ... END
(sometimes ':' is not enough)

routine_name(arg)

LET arg1 = arg
PROC RoutineName

LET arg1 = arg
GO SUB RoutineName

Routine call

PROCEDURE routine_name
BEGIN
...
END

DEFPROC RoutineName
...
ENDPROC

: REM RoutineName
...
RETURN

Routine declaration

t := routine_name(arg)

LET arg1 = arg
GO SUB NomeDaRotina
LET t = result

LET arg1 = arg
GO SUB RoutineName
LET t = result

routine function call

FUNCTION routine_name (arg:REAL):REAL;
BEGIN
...
END;

DEFPROC RoutineName
LET v = arg1
...
LET result = v
ENDPROC

: REM RoutineName
LET v = arg1
...
LET result = v
RETURN

routine função declaration

oranges_total := 0

LET OrangesTotal = 0

LET OrangesTotal = 0

Java language notation.
(Remember that a string array and a string variable
cannot have the same name  unlike the case for numbers)

oranges_total := 0

LET oranges total = 0

LET oranges total = 0

You can use spaces (they are ignored)
Warning: The BASinC emulador remove the spaces.
(Only numeric variables can have more than 1 caracter.)
