Print with comma

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Print with comma

Post by XavSnap »

10 PRINT AT 0,0;"HOW ARE YOU TODAY?"
30 PRINT AT 0,1;"%O",
This bug seem to erase the last Y,X+1 character, and set X to 0 or 16.


@bwinkel67:
30 PRINT AT 0,1;"%O",, = 30 PRINT AT 0,1;"%O";"<space>";TAB 16;"<space>";TAB 0;
:oops:

The 'PRINT ,' really display a space after the last Y,X pointer cursor.
10 FOR A=1 TO 44
20 PRINT "% % % % % % % % % % % % % % % % ";
30 NEXT A
35 PRINT AT 0,0;
40 FOR A=1 TO 20
50 PRINT TAB 4,,
60 NEXT A
Cap0033.jpg
Cap0033.jpg (6.59 KiB) Viewed 6371 times
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Print with comma

Post by XavSnap »

May be a "RST 10H" with a AF register set to 0, before the cursor location refresh !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Print with comma

Post by bwinkel67 »

More weird behavior on ZX81 BASIC.

This on the QL works as advertised resulting in either 1 when true or 0 when false (and is how it would work in most programming languages like C/C++). However, on ZX81 we get this:

PRINT 2 AND 17 -> results in 2
PRINT 17 AND 2 -> results in 17
PRINT 0 AND 17 -> results in 0
PRINT 17 AND 0 -> results in 0
PRINT 0 AND 0 -> results in 0

So if it's false it prints 0 but if it's true it takes the first argument.


With OR, the ZX81 is even less consistent (works as it should on the QL):

PRINT 2 OR 17 -> results in 1
PRINT 17 OR 2 -> results in 1
PRINT 0 OR 17 -> results in 1
PRINT 17 OR 0 -> results in 17
PRINT 0 OR 0 -> results in 0

So, OR results in 1 for all cases of true unless the second argument is false, then instead of 1 it results in the first argument???

Mind numbingly insane.
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Print with comma

Post by 1024MAK »

The ZX81 and ZX Spectrum BASIC treats any non-zero number as TRUE.

Hence the operation of AND and OR fits within this, returning zero if the expression result is false, and a non-zero value if the result is true.

The “strange” results often cause confusion. See the relevant section of the ZX81 BASIC manual exercise 3 and the ZX Spectrum BASIC manual.

I would have preferred binary bitwise operators myself :(

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer 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 later in the year.
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Print with comma

Post by 1024MAK »

85888CFC-E95B-4EE8-B0FB-E578B3E7B738.png
BD478588-8395-473C-9A0E-12A4DCC45892.png
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer 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 later in the year.
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Print with comma

Post by 1024MAK »

The above ties in with how IF works...
F4CEF82A-0690-4576-910F-B85595B37CCD.png
A070F88D-E8B6-4CEC-8364-97C2D6FD614C.png
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer 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 later in the year.
User avatar
XavSnap
Posts: 1941
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Print with comma

Post by XavSnap »

I would have preferred binary bitwise operators myself :(
Not False… But it's also True for me.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Print with comma

Post by bwinkel67 »

1024MAK wrote: Tue Apr 28, 2020 2:58 pm The ZX81 and ZX Spectrum BASIC treats any non-zero number as TRUE.

Hence the operation of AND and OR fits within this, returning zero if the expression result is false, and a non-zero value if the result is true.

The “strange” results often cause confusion. See the relevant section of the ZX81 BASIC manual exercise 3 and the ZX Spectrum BASIC manual.

I would have preferred binary bitwise operators myself :(

Mark
I don't mind that it has 0 as false and non-zero as true. But the unique and weird thing is the evaluation result of an AND and OR. Most languages and the QL will give a 1 for the result of and AND or OR but activate as true for any non-zero in an IF. For the ZX81 to return the first argument as true in AND and convert to a 1 for OR is inconsistent. At least if there was consistency I would expect 2 OR 17 to return 2 and 17 OR 2 to return 17, not that I like that. I'd prefer those results to all be 1. Whereas I'm fine with IF 17 THEN PRINT "HELLO" to work. This will need fixing on the ZXSimulator as a work-around :-/
Fruitcake
Posts: 351
Joined: Wed Sep 01, 2010 10:53 pm

Re: Print with comma

Post by Fruitcake »

1024MAK wrote: Tue Apr 28, 2020 2:58 pm I would have preferred binary bitwise operators myself :(
Which unlike the ZX81 and Spectrum is what the ZX80's AND and OR perform!
User avatar
mrtinb
Posts: 1910
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Print with comma

Post by mrtinb »

As the ZX81 uses a special calculator stack for most math operations, it is likely that the non zero integer was already on the stack, and to save time and space, it's easier just to return what is already there instead of replacing it with 1, to return 1.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
Post Reply