Pascalated BASIC to ZX Spectrum Converter

(No line numbers required)


Tutorial By Example

Lesson Date Title Edit Download
the 3 files
Run online
1 2022-02-25 Guess the Number
2 2022-03-04 Laser
3 2022-03-11 Multiplication Table
4 2022-03-18 Cannonball (Bala)
5 2022-03-25 The Hunter
6 2022-04-01 4 In a Line
7 2022-04-08 Pong
8 2022-04-15 Eagle 1 (Lander)
9 2022-04-22 15
10 2022-04-29 3D Graph z=F(xy)
11 2022-05-06 Hangman
12 2022-05-13 Asteroids Patrol
13 2022-05-20 The PI Obsession
14 2022-05-27 The Towers of Hanoi
15 2022-06-03 Space Invader
16 2022-06-10 Find Zero
17 2022-06-17 River Crossing ... ... ...
18 2022-06-24 Joker ... ... ...
19 2022-07-01 2D Graph ... ... ...
20 2022-07-08 Fair Shares (The Milk Divide) ... ... ...
21 2022-07-15 Maze Walls ... ... ...
22 2022-07-22 Klotski (big square) ... ... ...
23 2022-07-29 Torpedo ... ... ...
24 2022-08-05 The Lost Comic Book ... ... ...
25 2022-08-12 Worm ... ... ...
26 2022-08-19 Memory (hidden cards) ... ... ...
27 2022-08-26 Dogfight David ... ... ...
28 2022-09-02 The Towering Inferno ... ... ...
29 2022-09-09 The Blue Diamond ... ... ...
30 2022-09-16 Klox 2 ... ... ...
31 2022-09-23 TIM's Castle; Cube; Sea Battle (1 player, submarines) ... ... ...
2022-09-30 [Contest Deadline] Click here to access the
2022 Pascalated BASIC Contest


Pascalated BASIC
BASIC Apascalado

Structured BASIC
BASIC Estruturado

LINE STEP =

History

Structured programming appears in 1958 with ALGOL 58.
Structured programming became widely known in 1983 with Turbo Pascal 3 from Borland.
In 1984 the Sinclair QL made it possible to program in structured BASIC, although still with line numbers.
Structured BASIC without line numbers appeared in 1985 with QuickBASIC and QBASIC.
Pascalated BASIC (ZX Spectrum) appeared in 1987 in MicroSe7e journal.
Pascalated BASIC became a reality 30 years later with NextBASIC from ZX Spectrum Next.


Instructions

Usage of Pascalated editor
Simple write or paste your program on the left side text area.
The editor accepts either a ZX Spectrum structured 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 Pascalated 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 starting program at the beginning of this page.
Modify the program at the beginning of this page and write a new program.
Study the tutorial programs at the beginning 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_name(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
		

	

Programas de demonstração escritos em BASIC Apascalado em 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, 2021 by ZarSoft