I wrote a few 48k BASIC programs back in the eighties, which were published by Sinclair User. To save space, I used variables for some of the commonly used numbers, e.g. a=1, b=2, c=3, etc. One of these programs I would like to develop more. To easily understand what I had written around 35 years ago is quite difficult with letters for numbers. Yes, I could manually replace all the variables with their relevant values but that would be a fiddly job and is prone to mistakes being made. Does anyone know of a program which could list the program variables with an option to automatically update all occurrences of those variables with their correct number value? Hope this makes sense!
Cheers, Martin.
Variables replacement with numbers
-
- Drutt
- Posts: 18
- Joined: Mon Oct 31, 2022 11:04 am
Re: Variables replacement with numbers
There is a machine code routine to list the program variables in Hewson's "40 Best Machine Code Routines" - which I've already tested and have as an .ASM file that can be pasted into Spin's Z80 assembler.Martin Page wrote: ↑Mon Oct 31, 2022 11:22 am Does anyone know of a program which could list the program variables with an option to automatically update all occurrences of those variables with their correct number value? Hope this makes sense!
Or, this is a roundabout way of seeing the variables: either load it into BASin, or, if that doesn't work, LLIST it with Fuse (make sure "Emulate printers" is checked...) and edit the .TXT file to remove all the carriage returns after 32 characters. Then, rename it to .BAS and open with BASin, run it, and there will be a window showing what variables are defined and what their values are.
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
-
- Drutt
- Posts: 18
- Joined: Mon Oct 31, 2022 11:04 am
Re: Variables replacement with numbers
Yes, guilty as charged!
PeterJ wrote: ↑Mon Oct 31, 2022 11:56 am Welcome @Martin Page,
Are these yours?
https://spectrumcomputing.co.uk/list?label_id=9320
Re: Variables replacement with numbers
Welcome to this great forum.
Forest of Long Shadows is an excellent game and is always in my top 10 of favourite Speccy games.
-
- Drutt
- Posts: 18
- Joined: Mon Oct 31, 2022 11:04 am
-
- Drutt
- Posts: 18
- Joined: Mon Oct 31, 2022 11:04 am
Re: Variables replacement with numbers
Thanks for the info.TMD2003 wrote: ↑Mon Oct 31, 2022 12:10 pm There is a machine code routine to list the program variables in Hewson's "40 Best Machine Code Routines" - which I've already tested and have as an .ASM file that can be pasted into Spin's Z80 assembler.
Or, this is a roundabout way of seeing the variables: either load it into BASin, or, if that doesn't work, LLIST it with Fuse (make sure "Emulate printers" is checked...) and edit the .TXT file to remove all the carriage returns after 32 characters. Then, rename it to .BAS and open with BASin, run it, and there will be a window showing what variables are defined and what their values are.
Cheers, Martin.
Re: Variables replacement with numbers
Hi Martin,
My suggestion would be to install fuse-utils:
https://sourceforge.net/projects/fuse-e ... ils/1.4.3/
In there is a tool called listbasic that can convert a BASIC program within a .tap file into a modern text file. Then you can edit it in any modern code editor. E.g. Sublime (with my syntax highlighter for instance - see link in my sig). You'd be able to use a regular find&replace to convert your variables back to numbers.
Then you can use zmakebas to build your text file back into a tap file to test on a Spectrum emulator:
https://github.com/ohnosec/zmakebas
My suggestion would be to install fuse-utils:
https://sourceforge.net/projects/fuse-e ... ils/1.4.3/
In there is a tool called listbasic that can convert a BASIC program within a .tap file into a modern text file. Then you can edit it in any modern code editor. E.g. Sublime (with my syntax highlighter for instance - see link in my sig). You'd be able to use a regular find&replace to convert your variables back to numbers.
Then you can use zmakebas to build your text file back into a tap file to test on a Spectrum emulator:
https://github.com/ohnosec/zmakebas
Re: Variables replacement with numbers
Use my MultiSearch from Your Spectrum issue 12
http://www.users.globalnet.co.uk/~jg27p ... r12_47.htm
I also find it handy for eliminating spurious %s in NextBASIC after renumbering.
https://simon.mooli.org.uk/nextech/index.html#NoGo
Two cheers for compatibility!
http://www.users.globalnet.co.uk/~jg27p ... r12_47.htm
I also find it handy for eliminating spurious %s in NextBASIC after renumbering.
https://simon.mooli.org.uk/nextech/index.html#NoGo
Two cheers for compatibility!