Print with comma

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Print with comma

Post by bwinkel67 »

So I'm curious why ZX81 BASIC will put a clear block after a comma. Old ZX81 ROM bug perhaps?

If you try these two statements you'll see what I mean:

Code: Select all

10 PRINT AT 0,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
30 PRINT AT 0,0;"%H%O%W% %A%R%E% %Y%O%U% %T%O%D%A%%Y%?",
This one is just as curious. It puts the clear space after both inverse "?" even though the tab would be middle of screen for the 2nd line.

Code: Select all

10 PRINT AT 0,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
20 PRINT AT 1,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
30 PRINT AT 0,0;"%H%O%W% %A%R%E% %Y%O%U% %T%O%D%A%%Y%?","%?",
Both these tried on EightyOne v1.16 but I' assuming it's uniform since it uses the ZX81 ROM.
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Print with comma

Post by Paul »

Hello bwinkel67
Well Shure this is a RTFM thread, but we are a kind forum and so I will answer this question:
A Semikolon as a separator will print the next print directly after the last print. A comma is something like a tabulator. It adds blanks till the next tabulator place while print with no separator (only at the end of a print statement) will let the next print start in the next line.
This is not a ROM issue but a Basic standard not only in ZX80, ZX81, Spectrum, QL and Z88 but in any Basic Dialekt I came across.
Kind regards Paul
In theory, there is no difference between theory and practice. But, in practice, there is.
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Print with comma

Post by bwinkel67 »

Paul wrote: Fri Apr 24, 2020 11:30 am A comma is something like a tabulator. It adds blanks till the next tabulator place while print with no separator (only at the end of a print statement) will let the next print start in the next line.
Hi Paul,

Thanks for taking the time to respond. I think you misunderstood the question as I'm not asking how the comma in print works. I'm pointing out that in inverse video it acts strangely and am wondering if it is a ROM bug. I'm implementing my own ZX81 BASIC clone and in my implementation of commas I don't inadvertently print a clear space. See the picture below using the 2nd example of my previous post.

weirdcomma.png

And perhaps an easier picture of the code I am referring to.

code.png
User avatar
Paul
Posts: 1517
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Print with comma

Post by Paul »

What happens if you replace the comma with a semicolon and how does it look if you use the two variants when printing not in inverse?
This should point out where to search for the effect.
Kind regards Paul
In theory, there is no difference between theory and practice. But, in practice, there is.
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 FOR A=1 TO 44
20 PRINT "% % % % % % % % % % % % % % % % ";
30 NEXT A
35 PRINT AT 0,0;
40 FOR A=1 TO 44
50 PRINT ,
60 NEXT A
Where "% " = "\::"
Cap0032.jpg
Cap0032.jpg (5.93 KiB) Viewed 6604 times
Cap0031.jpg
Cap0031.jpg (6.54 KiB) Viewed 6604 times
All empty comma directive with PRINT delete the first next character tab(0) and tab(15).
In normal mode, it put a white space.
Use TAB 0 to go to the next line, to ovoid to erase the comma targeted character…
10 PRINT AT 0,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
20 PRINT AT 1,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
30 PRINT AT 0,0;"%H%O%W% %A%R%E% %Y%O%U% %T%O%D%A%Y% %?";TAB NOT PI;"%?";TAB NOT PI;
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 »

Paul wrote: Fri Apr 24, 2020 2:33 pm What happens if you replace the comma with a semicolon and how does it look if you use the two variants when printing not in inverse?
This should point out where to search for the effect.
Kind regards Paul
Substituting a semicolon works as expected, no white block appears.
bola_dor
Posts: 398
Joined: Wed Oct 02, 2019 5:32 am

Re: Print with comma

Post by bola_dor »

XavSnap wrote: Fri Apr 24, 2020 5:33 pm

All empty comma directive with PRINT delete the first next character tab(0) and tab(15).
In normal mode, it put a white space.

I didn't know this either
Do you mean that PRINT, has the same results as PRINT," "; ?
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come :D
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Print with comma

Post by bwinkel67 »

XavSnap wrote: Fri Apr 24, 2020 5:33 pm

Code: Select all

10 FOR A=1 TO 44
10 PRINT AT 0,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
20 PRINT AT 1,0;"\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::\::"
30 PRINT AT 0,0;"%H%O%W% %A%R%E% %Y%O%U% %T%O%D%A%Y% %?";TAB NOT PI;"%?";TAB NOT PI;
Don't know how you came up with the first image but your first program gave me the second image.

Note that I'm not looking for a work around. I'm trying to understand why ZX81 BASIC is doing that? It seems to be a bug, no? Why else put a blank space there. It somehow decides to print a blank space, likely to move the internal column pointer ahead by 1 so the next time it computes the "," it can add 16 and sees that it's greater than that. In my ZX81 BASIC clone (ZXSimulator which is only for the QL) I just set the internal column pointer to 0 (and increment row) if greater than 15 otherwise it's 16 and get the same effect when non-inverse and so I don't have this artifact. Do I want to be byte-for-byte (bug) compatible or has someone fixed this bug in updated ROM releases that speed things up, etc...

My question is, what is the use of putting a space after the commas each time (other than lazy internal way to keep column calculations on track)? After the comma you cannot print any text after it as it lands either on 0 or 16.

Note it even is an issue in non-inverse. In the bottom two examples it kind of messes up text (in the second one) that you'd like not to mess up. And yes, there are work around but just trying to understand the reason for why comma works that way:

This works

Code: Select all

10 PRINT AT 0,0;"HOW ARE YOU TODAY?"
30 PRINT AT 0,1;"%O"
This deletes the "W"

Code: Select all

10 PRINT AT 0,0;"HOW ARE YOU TODAY?"
30 PRINT AT 0,1;"%O",
So you may find this example useless but what if I create a display and I want to replace a pair of repeating numbers in a tabular display and they are in 0th and 16th column and there is text between and after them. Using the tabular comma would make the most sense. Or in my case, I was using it to move a line of text over three lines by using the "," in four successions which made it convenient in a single PRINT statement. When I inversed the screen all of a sudden the white spaces appeared so I had to use two PRINT statements (could have used TAB but haven't implemented it yet in ZXSimulator since I only recently realized it existed :-/).
Last edited by bwinkel67 on Fri Apr 24, 2020 11:26 pm, edited 5 times in total.
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: Print with comma

Post by bwinkel67 »

bola_dor wrote: Fri Apr 24, 2020 9:43 pm I didn't know this either
Do you mean that PRINT, has the same results as PRINT," "; ?
No, I don't think it's the same result as the first print puts a " " right at where the current cursor is before tabbing to the middle/next-line for the comma and the second print puts a " " at either the middle (16) or the next line (0) for the commas depending on where the cursor was.
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 »

bola_dor wrote: Fri Apr 24, 2020 9:43 pm I didn't know this either
Do you mean that PRINT, has the same results as PRINT," "; ?
Yes, i ever experiment this "bug" to save memory like "HELLO<space><...><space><space><N/L>" ="HELLO",,

@bwinkel67 : PRINT,=PRINT TAB (0);"<space>"; with a wrong column coord… PRINT AT Y,X-1 ! (where x=0 or 16)
It's a :mrgreen: a bug !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply