ZXtool - intimately examine P files

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
User avatar
yerzmyey
Posts: 1240
Joined: Thu May 15, 2008 10:11 am
Location: Rubber Planet
Contact:

Re: ZXtool - intimately examine P files

Post by yerzmyey »

Hi,

> Note which line numbers are a target for a GOSUB, or GOTO. If there are any computed GOTOs then extra care is needed.
> Any line which is a target needs to be given a label, and any line referencing the target line needs to have the line number
> changed from a value to a label like this:
(...)
Note that label definitions are given a colon, and references are not. If the GOTO target is variable, make sure the variable or expression uses the label instead of the base line number.
------------------------
So if I prepared earlier all the lines' numbers and GOTOs with a proper order, still I would have to do those things mentioned above?
IN NIHILUM REVERTERIS - a big text-adventure game for ZX81: http://tiny.pl/g2m6m
"MONOCHROME" issue 5 - (Spring 2014) free paper/PDF magazine about ZX81: http://tiny.pl/q2m44
ZX81 COMPETITIONS 2007/2009: http://zx81.republika.pl/
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXtool - intimately examine P files

Post by sirmorris »

If you are happy with your programs line numbering, then you don't need to do this.

You can simply tag the new code onto the end after you've made sure there are no line number clashes. Save it as BASE (for example). Then you'd run;

ZXTEXT2P BASE.TXT -o BASE.P


And you should have your combined program :)

C
User avatar
yerzmyey
Posts: 1240
Joined: Thu May 15, 2008 10:11 am
Location: Rubber Planet
Contact:

Re: ZXtool - intimately examine P files

Post by yerzmyey »

Ah, it worked just fine!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thanx a lot!!! :) :) :) :) :) :) :)


PS: Of course now I have _another_ problem ;) but it's not related with this thread, so I will mention it somewhere else. ;)
IN NIHILUM REVERTERIS - a big text-adventure game for ZX81: http://tiny.pl/g2m6m
"MONOCHROME" issue 5 - (Spring 2014) free paper/PDF magazine about ZX81: http://tiny.pl/q2m44
ZX81 COMPETITIONS 2007/2009: http://zx81.republika.pl/
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXtool - intimately examine P files

Post by bwinkel67 »

Is there an option in zxtool.exe to specify the format of "" in a string? In the zxtext2p.exe program it states that double quotes is specified via \" but when you grab a .p file and convert it into a text file it actually just gives you double "" with no escape character.

So zxtool.exe gives you code like this:

Code: Select all

10 PRINT "PRESS ""1"" TO CONTINUE"
Whereas zxtext2p.exe says it wants code like this:

Code: Select all

10 PRINT "PRESS \"1\" TO CONTINUE"
If you give zxtext2p.exe a file with "" it just moves it into a .p file and then EightyOne doesn't know what to do with it. (i.e. it loads but doesn't work properly) If you take a .p file that's proper and use zxtool.exe it gives "" and not \" so there seems to be a mismatch. I was hoping you could use an argument.
Fruitcake
Posts: 346
Joined: Wed Sep 01, 2010 10:53 pm

Re: ZXtool - intimately examine P files

Post by Fruitcake »

bwinkel67 wrote: Wed Apr 29, 2020 10:08 am If you give zxtext2p.exe a file with "" it just moves it into a .p file and then EightyOne doesn't know what to do with it.
EightyOne V1.13 and up directly supports importing text files and converting them into programs. It is based on the formatting used by zxtext2p to achieve a high level of compatibility but extends it to correctly handle the double quote symbol when found in a listing. It will however also correctly convert \" if it finds it in a listing. You just need to give the text file an extension of .B81 for ZX81 programs (or .B80 for ZX80 and .B82 for Spectrum programs).

Arguably zxtext2p should be updated to handle the double quote case and then all tools would be in alignment. Unless you explicitly need to use a stand-alone conversion program then you should be able to achieve all you want directly using EightyOne.
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXtool - intimately examine P files

Post by bwinkel67 »

Fruitcake wrote: Wed Apr 29, 2020 1:12 pm EightyOne V1.13 and up directly supports importing text files and converting them into programs. It is based on the formatting used by zxtext2p to achieve a high level of compatibility but extends it to correctly handle the double quote symbol when found in a listing. It will however also correctly convert \" if it finds it in a listing. You just need to give the text file an extension of .B81 for ZX81 programs (or .B80 for ZX80 and .B82 for Spectrum programs).

Arguably zxtext2p should be updated to handle the double quote case and then all tools would be in alignment. Unless you explicitly need to use a stand-alone conversion program then you should be able to achieve all you want directly using EightyOne.
I'm using EightyOne v1.16 and it did not handle "" properly when I used zxtool to convert a .p file to text and then zxtext2p to convert it back to .p (loading in the latter). I'm writing a BASIC simulator so I kind of want both tools to work and I conform to the zxtext2p standard (i.e. \" for double space). But it seems that zxtool kind of breaks the rules by not using \" and just throwing two double quotes in ("") and does nothing and EightyOne v1.16 reads it in but won't display those PRINT statements (same as my ZXSimulator so at least the two are compatible though mine just barfs and won't even run the PRINTs, giving an error instead). So it' seems that it is zxtool that may need updating not zxtext2p, no?
Last edited by bwinkel67 on Thu Apr 30, 2020 3:16 am, edited 1 time in total.
Fruitcake
Posts: 346
Joined: Wed Sep 01, 2010 10:53 pm

Re: ZXtool - intimately examine P files

Post by Fruitcake »

bwinkel67 wrote: Wed Apr 29, 2020 7:01 pm So it' seems that it is zxtool that may need updating no zxtext2p, no?
Or the zxtool could be updated and then all 3 would still be in alignment...

It seems a shame zxtext2p uses \" rather than "" since the latter looks more like a BASIC listing, and it is possible to reliably detect it within PRINT statements and so no real necessity to escape it.

As you say, an argument on zxtool could be a solution to the issue.
bwinkel67
Posts: 147
Joined: Mon Mar 23, 2020 2:38 am

Re: ZXtool - intimately examine P files

Post by bwinkel67 »

Fruitcake wrote: Thu Apr 30, 2020 12:41 am [It seems a shame zxtext2p uses \" rather than "" since the latter looks more like a BASIC listing, and it is possible to reliably detect it within PRINT statements and so no real necessity to escape it.
A bit confusing here so let me get clarity.

With regard to \" in source text file:
  • EightyOne version 1.16 works with this when using a zxtext2p.exe converted text-to-.p file
  • ZXSimulator (current version) works with this when using source text file
With regard to "" in source text file:
  • EightyOne version 1.16 fails with this when using a zxtext2p.exe converted text-to-.p file
  • ZXSimulator (current version) fails with this when using source text file
So I suppose that leaves EightyOne directly reading source text files. Are you saying that EightyOne will directly read in "" and treat it properly from text?

The problem with accepting "" is that you have to then add context when reading in a file so that whenever you see the first " you don't count it (starting a string) but when you see the next " you check if it is followed right away by another " and if not you close the string otherwise you treat it as the "" symbol. Whereas with zxtext2p format when you see the escape character you check to see if the next one is " and if so , voila, you have "" symbol. So much easier algorithmically to deal with the \" than just adding "" double quotes. And as far as looks goes, well, the \" is embedded in code that also has %I%N%V%E%R%S%E formatting and graphics like \:: for inverse space, etc. so having \" doesn't stand out as much as "" does.

Are there other variations to graphics and inverse formatting? I do see {#} which I assume prints the character with the character code of #.
Fruitcake
Posts: 346
Joined: Wed Sep 01, 2010 10:53 pm

Re: ZXtool - intimately examine P files

Post by Fruitcake »

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am With regard to \" in source text file:
•EightyOne version 1.16 works with this when using a zxtext2p.exe converted text-to-.p file
Yes, zxtext2p successfully converts \" and produces a valid .p file and so EightyOne can read it in and run it.

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am With regard to "" in source text file:
•EightyOne version 1.16 fails with this when using a zxtext2p.exe converted text-to-.p file
zxtext2p does not correctly convert "" and so produces an invalid .p file which has two " rather than a single "" character. EightyOne will read in the .p file but it won't run becuase the BASIC program is invalid.

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am Are you saying that EightyOne will directly read in "" and treat it properly from text?
Yes.

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am The problem with accepting "" is that you have to then add context when reading in a file so that whenever you see the first " you don't count it (starting a string) but when you see the next " you check if it is followed right away by another " and if not you close the string otherwise you treat it as the "" symbol. Whereas with zxtext2p format when you see the escape character you check to see if the next one is " and if so , voila, you have "" symbol. So much easier algorithmically to deal with the \" than just adding "" double quotes.
It is true it adds complexity to support "" but the focus should surely be on whether it makes things easier for the user... I can see a case for both approaches.

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am And as far as looks goes, well, the \" is embedded in code that also has %I%N%V%E%R%S%E formatting and graphics like \:: for inverse space, etc. so having \" doesn't stand out as much as "" does.
Perhaps but there is no real necessity to escape it like there is with these other characters. After all, ** is supported directly instead of \*...

EightyOne supports both "" and \" to allow people to choose which style they prefer. Perhaps taking that argument further, both zxtext2p and zxtool should support "" and \" then every combination is covered...

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am Are there other variations to graphics and inverse formatting?
I don't believe so in zxtext2p. In EightyOne, any byte value can be specified as an escape sequence consisting of 2 hex digits, e.g. \80 for an inverse space, and so graphics and inverse characters could be specified like this, but that formatting is mainly intended for use in REM statements that contain machine code. There's a help page in EightyOne that lists the extensions it supports in addition to the zxtext2p format.

bwinkel67 wrote: Thu Apr 30, 2020 3:15 am I do see {#} which I assume prints the character with the character code of #.
zxtext2p uses # for a comment line which it simply ignores when converting the file:
http://freestuff.grok.co.uk/zxtext2p/index.html
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: ZXtool - intimately examine P files

Post by mrtinb »

It would be cool, if it just picked any unicode char for each ZX81-char. I think it would be easier to read, and most external programs support unicode. Only a handful ZX81-chars does not exist in unicode.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
Post Reply