ZX BASIC
|
javascript
|
example
|
BORDER color
|
BORDER( color )
|
BORDER( 1 )
|
CLS
|
CLS()
|
CLS()
|
DATA d1,d2,d3 RESTORE line_number READ v1,v2,v3
|
DATA(d1,d2,d3) RESTORE(function_name) v1 = READ()
|
function ages() {
DATA("david",19)
}
function main() {
RESTORE(ages)
name = READ()
age = READ()
}
|
DRAW dx,dy
|
DRAW(dx,dy)
|
DRAW(20,10)
|
|
FILL(x,y,margin_color) FILL(x,y,substitute_color)
|
FILL(128,64,5) FILL(128,64,-1)
|
INK color
|
INK(color)
|
INK(4)
|
INKEY$
|
INKEY$()
|
a$ = INKEY$()
|
INPUT n INPUT s$
|
n = await INPUT() s$ = await INPUT$()
|
n = await INPUT() s$ = await INPUT$()
|
OVER n
|
OVER(mode)
|
OVER(0) OVER(1) OVER(2)
|
PAPER color
|
PAPER(color)
|
PAPER(2)
|
PAUSE frames
|
await PAUSE(frames)
|
await PAUSE(50)
|
PEEK memory_address
|
PEEK( ascii_address )
|
PEEK( USR("3") ) PEEK( 65*8 )
|
|
PIANO( organ_or_piano_mode )
|
PIANO(1)
|
PLOT x,y
|
PLOT(x,y)
|
PLOT(128,96)
|
POINT coordinates
|
POINT( x,y )
|
color = POINT(255,191)
|
POKE memory_address
|
POKE( ascii_address )
|
POKE( USR("3"), 255 ) POKE( 65*8, 0 )
|
PRINT AT lin,col; PRINT TAB col;
|
AT(lin,col) TAB(col)
|
AT(2,3) TAB(5)
|
PRINT arg PRINT arg;
|
PRINTLN(arg) PRINT(arg)
|
PRINTLN("Hello") PRINT(123)
|
RANDOMIZE RANDOMIZE seed
|
RANDOMIZE() RANDOMIZE(seed)
|
RANDOMIZE() RANDOMIZE(123)
|
SCROLL (available on ZX81)
|
SCROLL()
|
SCROLL()
|
|
SOUND( beep_or_piano_mode )
|
SOUND(1)
|
USR "A" USR "U"
|
USR( ascii_char ) USR( ascii_code )
|
USR( "3" ) USR( 255 )
|
|
Math constants:
PI
Math operations:
a AND b ==> a && b
a OR b ==> a || b
NOT a ==> !a NOT(a)
a = b ==> a == b
b ^ e ==> POW(b,e)
a-b*INT(a/b) ==> a % b
Math functions:
positive = ABS(real)
real = ACS(real)
real = ASN(real)
real = ATN(real)
decimal = BIN( binary_string$ )
character$ = CHR$( ASCII_code )
ASCII_code = CODE( character$ )
real = COS(real)
binary$ = DEC$(decimal_integer)
real = EXP(real)
integer = INT(real)
length = LEN( string$ )
real = LN(real)
boolean = NOT(number)
power = POW(base,exponent)
real = RND()
integer = SGN(real)
real = SIN(real)
real = SQR(real)
string$ = STR$( real )
real = TAN(real)
string$ = TO$( string$, start, end )
address = USR(char$)
address = USR(code)
real = VAL(string$)
Note
In javascript, lowercase and uppercase identifiers are different.
In javascript, strings start at 0 index!
Example in BASIC: LET t$ = s$( 1 TO LEN(s$) )
Example in javascript: t$ = TO( s$, 0, LEN(s$)-1 )
In javascript "^" is a different operation.
Instead of base^exponent
you should use POW(base,exponent)
In javascript you cannot modify a string.
Instead of LET s$[5] = "A"
you should use s$ = TO$( s$, 0, 4-1 ) + "A" + TO$( s$, 4+1, LEN(s$)-1 )
(Because strings start at 0 index, 5 become 4.)
|