ZX Basic vs Commodore V2.00 (Vic 20)
Re: ZX Basic vs Commodore V2.00 (Vic 20)
Yes Sinclair Basic is more dynamic here. E.g. GOTO VARNAME works fine in Sinclair Basic, but gives an error in Commodore Basic, where GOTO and GOSUB can only be followed by a number.
Re: ZX Basic vs Commodore V2.00 (Vic 20)
That would require a GOSUB or GOTO.
Regards,
Shaun.
Last edited by Shaun_B on Wed Dec 12, 2018 9:27 pm, edited 1 time in total.
Re: ZX Basic vs Commodore V2.00 (Vic 20)
A quirk of Microsoft (Commodore) BASIC is that you can do this:
Code: Select all
100 GOSUB 1000 UPDATE SCORE:PRINT S
999 END
1000 S=S+10:RETURN
Any variable length of more than two characters in Commodore BASIC will ignore everything after the 2nd char. So LET SCA = 100: LET SCB = 101: PRINT SCA will produce the result for the latter declaration (101).
Regards,
Shaun.
Re: ZX Basic vs Commodore V2.00 (Vic 20)
Not sure what you're driving at but no GOSUB or GOTO is required when defining a function within a string or its later evaluation.
IE..
10 INPUT A
20 INPUT B
30 INPUT X
40 LET Z$="A*B/SIN X"
50 PRINT VAL Z$
Functioned defined within Z$ and evaluated in line 50 using the variables previously input and if the program is written in what was used to be termed the "call and fall" manner then I can't see where the GOTO etc fits in?
Or are you meaning a defined funtion pointing to a jump to a line number?
Re: ZX Basic vs Commodore V2.00 (Vic 20)
CBM BASIC V2 can't do string functions for sure, but this:Moggy wrote: ↑Wed Dec 12, 2018 10:19 pm
Not sure what you're driving at but no GOSUB or GOTO is required when defining a function within a string or its later evaluation.
IE..
10 INPUT A
20 INPUT B
30 INPUT X
40 LET Z$="A*B/SIN X"
50 PRINT VAL Z$
Functioned defined within Z$ and evaluated in line 50 using the variables previously input and if the program is written in what was used to be termed the "call and fall" manner then I can't see where the GOTO etc fits in?
Or are you meaning a defined funtion pointing to a jump to a line number?
Code: Select all
0 DEF FN A(X) = X * X
100 PRINT FN A(10)
200 PRINT FN A(20)
300 PRINT FN A(30)
400 A=FN A(11)
500 PRINT A
Shaun.
Re: ZX Basic vs Commodore V2.00 (Vic 20)
have not posted in a while, forgot I was even still here, thought they had forgot about me. hope the rams win SB LIII
In Heck, there are two options for perpetual torment:
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Re: ZX Basic vs Commodore V2.00 (Vic 20)
Sinclair ZX81 BASIC has GOTO N and GOSUB N, where N can be an expression; this doesn't work in CBM BASIC V2 for VIC20/C64, but it has ON N GOTO n1,n2,n3,... and ON N GOSUB n1,n2,n3,..., where N is an expression and n1,n2,n3 etc. are fixed numbers. One can simulate ON N GOTO/GOSUB in ZX81 BASIC with e.g.:
4080 GOTO (S=1)*1560+(S=2)*2780+(S=3)*3630+(S=4)*3680+(S=5)*3730
corresponds to:
4080 ON S GOTO 1560,2780,3630,3680,3730
In BASIC V2 if S>5 it goes to the next line, but that could also be simulated in ZX81 BASIC by adding +(S>5)*4081 to the line above.
In ZX81 BASIC logical expressions are 0 and 1 (with exception for short circuit AND), but in BASICV2 they are 0 and -1 and the logical/boolean operators (NOT, AND, OR) are bitwise, but in ZX81 BASIC they are not.
The ZX81 screen doesn't scroll by itself so you have to do SCROLL, otherwise you get a screen full error when PRINT:ing on the next line after the last, but then you can CONT:inue.
ZX81 has PRINT AT R,C, but BASIC V2 has cursor control codes; you can PRINT a code for HOME and then PRINT codes for DOWN and RIGHT several times, alternatively there is a VIC20 Kernal (i.e. ROM) routine for cursor positioning, but that requires POKEs and calling ROM.
INPUT is always on the last line in ZX81 BASIC and that is a disadvantage, but you can write your own input subroutines using INKEY$.
In ZX81 BASIC in VAL A$, A$ can be an INPUT:ed expression in a string that evaluate to a number, but that doesn't work in BASIC V2 and DEF FN can not be changed to INPUT:ed strings. In ZX Spectrum BASIC VAL$ was added.
Some variable names in ZX81 can only be one character long, e.g. AB$, AB(), AB$(), FOR AB are not allowed, but in BASIC V2 all variables can have long names, but only the two first characters matters, the rest are just a sort of comment, but in ZX81 all characters in long variable names matters. Also in ZX81 e.g. A$ and A$() are the same variable and not different as in V2, this is because ZX uses array index notation to pick a character e.g. A$(N), and not MID$(A$,N,1).
The Sinclair developed ZX81 BASIC was slow, but the later, fan developed, versions are much faster and fully compatible.
ZX81 BASIC is only 7.5 KiB since the character font is stored in the ROM (last 0.5 KiB). I believe ZX81 only costed 1/3 of the VIC20 and had a higher profit margin. It took a long time after the sale of ZX81 stopped before it was possible to buy a new computer system with keyboard, power supply, screen, and secondary storage that costed as little as Sinclair ZX81 with a B/W TV and cassette player.
4080 GOTO (S=1)*1560+(S=2)*2780+(S=3)*3630+(S=4)*3680+(S=5)*3730
corresponds to:
4080 ON S GOTO 1560,2780,3630,3680,3730
In BASIC V2 if S>5 it goes to the next line, but that could also be simulated in ZX81 BASIC by adding +(S>5)*4081 to the line above.
In ZX81 BASIC logical expressions are 0 and 1 (with exception for short circuit AND), but in BASICV2 they are 0 and -1 and the logical/boolean operators (NOT, AND, OR) are bitwise, but in ZX81 BASIC they are not.
The ZX81 screen doesn't scroll by itself so you have to do SCROLL, otherwise you get a screen full error when PRINT:ing on the next line after the last, but then you can CONT:inue.
ZX81 has PRINT AT R,C, but BASIC V2 has cursor control codes; you can PRINT a code for HOME and then PRINT codes for DOWN and RIGHT several times, alternatively there is a VIC20 Kernal (i.e. ROM) routine for cursor positioning, but that requires POKEs and calling ROM.
INPUT is always on the last line in ZX81 BASIC and that is a disadvantage, but you can write your own input subroutines using INKEY$.
In ZX81 BASIC in VAL A$, A$ can be an INPUT:ed expression in a string that evaluate to a number, but that doesn't work in BASIC V2 and DEF FN can not be changed to INPUT:ed strings. In ZX Spectrum BASIC VAL$ was added.
Some variable names in ZX81 can only be one character long, e.g. AB$, AB(), AB$(), FOR AB are not allowed, but in BASIC V2 all variables can have long names, but only the two first characters matters, the rest are just a sort of comment, but in ZX81 all characters in long variable names matters. Also in ZX81 e.g. A$ and A$() are the same variable and not different as in V2, this is because ZX uses array index notation to pick a character e.g. A$(N), and not MID$(A$,N,1).
The Sinclair developed ZX81 BASIC was slow, but the later, fan developed, versions are much faster and fully compatible.
ZX81 BASIC is only 7.5 KiB since the character font is stored in the ROM (last 0.5 KiB). I believe ZX81 only costed 1/3 of the VIC20 and had a higher profit margin. It took a long time after the sale of ZX81 stopped before it was possible to buy a new computer system with keyboard, power supply, screen, and secondary storage that costed as little as Sinclair ZX81 with a B/W TV and cassette player.
Last edited by MOB-i-L on Sat Feb 05, 2022 9:27 pm, edited 2 times in total.
Started w/ BASIC on ABC80 & ZX81 then Forth, Z80… http://scratch.mit.edu/users/mobluse/ https://www.youtube.com/user/MOBiL4u/ https://twitter.com/mobluse/
Re: ZX Basic vs Commodore V2.00 (Vic 20)
There's five variables type on the Zx81 Basic...Some variable names in ZX81 can only be one character long, e.g. AB$, AB(), AB$(), FOR AB is not allowed.
1- Boolean. (can be an integer or a floating point value)
Characters:
2- Free length string = 1 LET A$="HELLO WORD"
3- Fix length string = 1 DIM A$(1,32) Where "HELLO WORD" will take 32 characters... A$=""HELLO WORD"+22 spaces.
Numerics:
4- INTEGER: 1 FOR a=0 TO 10 (only 1 character in the variable name!)
5- Floating point: 1 LET A=1 ("open bar" in the variable name)
Variable name length:
Numeric Array = Only one character : "1 DIM a(1)"
Next/FOR integer = Only one character
Numeric LET = x character (memory room): "1 LET ABCDEFGHIJKLMNOPQRSTUVWXYZ=1"
Characters = Only one character: "1 LET A$="ABC""
In case of " LET PRINT=0" ; "LET THEN=1"; "LET TO=0";"LET NOT=0";"LET CODE=1"... it's working, but you had to type the variable name using alphanumeric letters.
"LET ABC12345=0" working too.
Note: It work on a true computer, on an emulator or a generic "TEXT2P", you had to choose another variables name to avoid to get a token instead of an alphanumeric name.
Due to a memory room problem, it's recommended to use only one character ... or two ... in a variable name !
1 LET ABCDEFGHIJKLMNOPQRSTUVWXYZ=1
2 LET ABCDEFGHIJKLMNOPQRSTUVWXYZ=ABCDEFGHIJKLMNOPQRSTUVWXYZ+1
Is correct...But...
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
- 1024MAK
- Posts: 5189
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: ZX Basic vs Commodore V2.00 (Vic 20)
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
Re: ZX Basic vs Commodore V2.00 (Vic 20)
or a floating point too...4- INTEGER: 1 FOR a=0 TO 10 (only 1 character in the variable name!)
Without the boolean, 3 kinds of variables...
You win Mark...
Xavier ...on the Facebook groupe : "Zx81 France"(fr)