You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/syntax.md
+24-10Lines changed: 24 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,20 @@
3
3
## Introduction
4
4
5
5
This page is about the ZX BASIC language syntax. It is part of the Language Reference Guide.
6
-
ZX BASIC aims to be a modern BASIC dialect but tries to keep some (many) of the original Sinclair BASIC features for the nostalgic. So you can use it in both ways.
6
+
ZX BASIC aims to be a modern BASIC dialect but tries to keep some (many) of the original Sinclair BASIC
7
+
features for the nostalgic. So you can use it in both ways.
7
8
8
-
The BASIC dialect is mainly based in [FreeBasic](http://www.zxbasic.net/wiki/). Many of the language specifications have been taken from there.
9
+
The BASIC dialect is mainly based in [FreeBasic](https://www.freebasic.net/wiki/DocToc).
10
+
Many of the language specifications have been taken from there.
9
11
10
12
## ZX BASIC syntax overview
11
13
12
-
If you have ever programmed in legacy BASIC (either Sinclair BASIC or any other flavour) you will already know that BASIC languages are **line oriented**. Each sentence or group of sentences are separated in lines (ended with a carriage return).
14
+
If you have ever programmed in legacy BASIC (either Sinclair BASIC or any other flavour) you will already know that
15
+
BASIC languages are **line oriented**. Each sentence or group of sentences are separated in lines (ended with a
16
+
carriage return).
13
17
14
-
Nowadays this is not necessary, but ZX BASIC allows you to use lines and line numbers for compatibility (and nostalgic!) reasons:
18
+
Nowadays this is not necessary, but ZX BASIC allows you to use lines and line numbers for compatibility
19
+
(and nostalgic!) reasons:
15
20
16
21
```basic
17
22
10 REM This is a comment.
@@ -52,7 +57,9 @@ PRINT _
52
57
53
58
### Sentences and block of sentences
54
59
55
-
A sentence is the simplest BASIC instruction (e.g. **[PRINT](print.md)**). Sentences might contain ''arguments'' and can be separated by a ''colon'' (:) as in Sinclair BASIC or by ''end of line''. A ''block of sentences'' are just a group of sentences one after another. Usually the reserved word **END** denotes the end of such block. E.g.
60
+
A sentence is the simplest BASIC instruction (e.g. **[PRINT](print.md)**). Sentences might contain ''arguments'' and
61
+
can be separated by a ''colon'' (:) as in Sinclair BASIC or by ''end of line''. A ''block of sentences'' are
62
+
just a group of sentences one after another. Usually the reserved word **END** denotes the end of such block. E.g.
56
63
57
64
```basic
58
65
IF a > b THEN
@@ -61,7 +68,8 @@ IF a > b THEN
61
68
END IF
62
69
```
63
70
64
-
In the previous example, everything between **[THEN](if.md)** and **[END IF](if.md)** conforms a ''block of sentences''. Some sentences (like the shown **[IF](if.md)**) works with sentences block. They are called ''compound sentences''.
71
+
In the previous example, everything between **[THEN](if.md)** and **[END IF](if.md)** conforms a ''block of sentences''.
72
+
Some sentences (like the shown **[IF](if.md)**) works with sentences block. They are called ''compound sentences''.
65
73
66
74
### Identifiers
67
75
@@ -85,7 +93,8 @@ So, `C9` hex should be written as `0C9h` or `$C9`.
85
93
86
94
### Comments
87
95
88
-
As shown in the previous examples, the ''reserved word'' **REM** is used for comments and ''remarks''. However, you can also use the single quote (') character for comments instead of **REM**:
96
+
As shown in the previous examples, the ''reserved word'' **REM** is used for comments and ''remarks''.
97
+
However, you can also use the single quote (') character for comments instead of **REM**:
89
98
90
99
```basic
91
100
10 REM This is a comment
@@ -143,7 +152,8 @@ A blank space represents both blocks blank or paper. The complete list of possib
143
152
144
153
### Embedded color control codes
145
154
146
-
Sometimes, in a program, one might wish to embed colour control codes into strings for printing. This is possible using the same schema as Paul Dunn's BASIC IDE BASin.
155
+
Sometimes, in a program, one might wish to embed colour control codes into strings for printing.
156
+
This is possible using the same schema as Paul Dunn's BASIC IDE BASin.
147
157
148
158
The escape sequences for control characters are as follows:
149
159
@@ -157,11 +167,15 @@ So, for example, an embedded control code for red ink would be `\{i2}`.
157
167
158
168
## Data types
159
169
160
-
ZX Basic [types](types.md) ranges from 8 to 32 bits for integer formats. It also supports floating point format (the ZX ROM 40 bits floating point from the ROM FP Calculator) and ''Fixed'' for fixed point arithmetic. See [types page](types.md) for more information.
170
+
ZX Basic [types](types.md) ranges from 8 to 32 bits for integer formats. It also supports floating point format
171
+
(the ZX ROM 40 bits floating point from the ROM FP Calculator) and ''Fixed'' for fixed point arithmetic.
172
+
See [types page](types.md) for more information.
161
173
162
174
## Inline assembly
163
175
164
-
The Compiler supports inline assembly, starting with the ASM directive and ending with an END ASM directive. Between these two, raw z80 assembly becomes legal. This assembly data will be passed directly to the assembler as part of the compiled assembler source.
176
+
The Compiler supports inline assembly, starting with the ASM directive and ending with an END ASM directive.
177
+
Between these two, raw z80 assembly becomes legal. This assembly data will be passed directly to the assembler as part
178
+
of the compiled assembler source.
165
179
166
180
Note that the rules for assembly change dramatically from standard ZX BASIC, and this mode is not for the unwary.
0 commit comments