Pascalated BASIC to ZX Spectrum Converter

No line numbers required

(Pascalated BASIC dont't use line numbers)


Pascalated BASIC
BASIC Apascalado

Structured BASIC
BASIC Estruturado

LINE STEP =

Instructions

Usage of Pascalated editor
Simple write or paste your program on the left side text area.
The editor accepts either a ZX Spectrum program or a Pascalated version.
When you're done copy the program on the right side text area to an emulator (try BASinC).
If you make changes to the Structured BASIC program then you can paste it on the left text area and it will be converted back to Pascalated BASIC.
Usage of BASinC emulator
To run the program, select the BASIC Structured text (CTRL-A), copy (CTRL-C) and paste (CTRL-V) on BASinC emulator.
To copy a program from BASinC to Pascalated editor, use Edit/Copy_Listing and paste the text on the Pascalted editor.
On BASinC, to export BASIC text you must save with BAS extension (click SAVE and choose extension BAS).
On BASinC, to export snapshop use File/Export_Tap or SAVE with extension BAS,SNA,Z80.
Structured BASIC sintax (ZX Spectrum)
Do not use GOTOs
Each program is a set of routines.
Each routine starts with ": REM RoutineName".
Each routine ends with "RETURN".
The first routine must end with a "STOP" instead of a "RETURN".
Reserved words must be on upper case.
Pascalated sintax
Do not try to use GOTOs
Each program is a set of routines.
Each routine starts with "DEFPROC RoutineName" and ends with "ENDPROC".
The first routine must begin with "PROGRAM ProgramName" and ends with an "END" instead of "ENDPROC".
Reserved words must be on upper case.
Each Pascalated command must be on a separately line (at the beginning of the line). This also applied to the command FOR-NEXT.
Reserved words of Pascalated BASIC
PROGRAM and END comes from Pascal programming language.
REPEAT, UNTIL and WHILE comes from Pascal and BASICNext of ZX Spectrum Next.
DEFPROC, ENDPROC and PROC comes from BASICNext of ZX Spectrum Next.
IF-BEGIN-ELSEIF-ENDIF comes from various languages.
More info
Read the Pascal to BASIC translations below.
Study the program at the beginning of this page.
Modify the program at the beginning of this page and write a new program.
Try the 1987 programs at the end of this page.

Sintax

	
	

Pascal

Pascalated BASIC

ZX Spectrum BASIC

Note


REPEAT 
  ...
UNTIL condition; 			
		

REPEAT variable
  ...
UNTIL condition; 			
		

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

REPEAT	
(variable must have only 1 char)
(be careful: the variable cannot be used by another cicle at the same time)		
		

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 needed)			
		

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 IF-BEGIN
FOR i = i TO 0.5 STEP -1 : REM IF-BEGIN
  ...
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
		

procedure call
		

PROCEDURE routine_name
BEGIN
  ...
END
		

DEFPROC RoutineName 
  ...
ENDPROC
		

: REM RoutineName		
  ...
RETURN
		

procedure declaration
		

t := routine(arg)
		

LET arg1 = arg
GO SUB RoutineName
LET t = result
		

LET arg1 = arg
GO SUB RoutineName
LET t = result
		

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 
		

function declaration
		

total_apples := 0
		

LET TotalApples = 0
		

LET TotalApples = 0
		

java notation
(Remember that a string array and a simple string variable 
cannot have the same name - unlike the case for numbers)
		

total_apples := 0
		

LET total apples = 0
		

LET total apples = 0
		

you can use spaces (they are ignored)
but the BASinC emulator removes the spaces
(only numeric variables can have more than 1 char)
		
Each Pascalated command must be on a separately line. 
The command FOR-NEXT also must be at the beginning of the line.
  FOR i=1 TO 10 
    PRINT i 
  NEXT i
		
If you want to make an exception, start de line with an ":"
  : FOR i=1 TO 10 : PRINT i : NEXT i
		

Pascalated BASIC program demos from 1987

1 BASIC Apascalado 1 (factorial iterativo) (MicroSe7e 56) (1987) [Zarsoft].z80 2 (duas versões semelhantes) BASIC Apascalado 2 - Recursividade (factorial optimizado (memória)) (MicroSe7e 60) (1987) [Zarsoft].z80 BASIC Apascalado 2 - Recursividade (factorial rápido) (MicroSe7e 60) (1987) [Zarsoft].z80 3 BASIC Apascalado 3 - Recursividade sem stack (factorial) (MicroSe7e 61) (1988) [Zarsoft].z80 4 (2 versões semelhantes) BASIC Apascalado 4 - Recursividade (Torres de Hanoi) (versão1) (MicroSe7e 62) (1989) [Zarsoft].z80 BASIC Apascalado 4 - Recursividade (Torres de Hanoi) (versão2) (MicroSe7e 62) (1988) [Zarsoft].z80 8 BASIC Apascalado 8 - Automato (avaliar número) (MicroSe7e 66) (1988) [Zarsoft].z80 9 BASIC Apascalado 9 - A Vitória do Spectrum Next (2021) [ZarSoft].z80
Pascalated BASIC (c) 1987 by ZarSoft
Note: Pascalated BASIC became a reality 30 years later with BASICNext from ZX Spectrum Next.