COLON algorithm

Anything QL Software or Programming Related.
User avatar
tofro
Font of All Knowledge
Posts: 3010
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: COLON algorithm

Post by tofro »

Just a quick hint for a useful "hack":

Note you can totally MERGE a file with instructions, but no no line numbers in S*BASIC. If you do a MERGE "flp1_SETIT" and the file has the line "a = 12345" (just the BASIC instruction with no line number), the variable a will have the value 12345 after the MERGE.

This might be useful to avoid line number collisions in your program.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
ql_freak
Gold Card
Posts: 428
Joined: Sun Jan 18, 2015 1:29 am

Re: COLON algorithm

Post by ql_freak »

Hi,

I haven't tested your "colon" example, cause I do not need it and even don't know why it's needed on a multitasking operating system like QDOS (SMS...). Normally you switch on your QL and run your boot program, where you setup the directories of the PTH device and set the environment variables for all of your programs (a lot of programs now support environment variables, especially C programs compiled with C68 or GCC cross compiler and of course S*BASIC).

If you are using a BBQL with version before JS (extensions loaded in a SuperBASCIC program cannot be used in this program) you must split your boot program in 2 SuperBASIC programs (note: All programs only tested for syntax, I have not run them; i.e. they will load without MISTake):

boot (assuming your extensions are in "MDV1_etc_"):

Code: Select all

100 etc$='MDV1_etc_'
140 adr=RESPR(1516):LBYTES etc$&'Pth_rext',adr:call adr:REMark Load the Path device which supports a search path
180 adr=RESPR(896):LBYTES etc$&'env_bin',adr:call adr:REMark Load the environment variables support for QDOS
220 LRUN'MDV1_boot2'
boot2:

Code: Select all

100 REMark Just an example, you can add as many path names as you want
140 PTH_ADD'MDV1_'
180 PTH_ADD'MDV1_bin_'
220 PTH_ADD'MDV1_usr_bin_'
260 PTH_ADD'n2_MDV1_'
300 REMark Set data directory for a SuperBASIC program of your own:
340 SET_ENV'HOME=MDV2_home_popopo_'
380 REMark If you have Toolkit II you can (should) also use:
420 REMark PROG_USE'PTH1_'
460 REMark Then you can e. g. just use: LRUN myprog_bas
If you now want to start a program e.g. myDoWhatIAmThinking_bas just use:

LRUN PTH1_myDoWhatIAmThinking_bas

and it will find it if it is on MDV1_, MDV1_bin_, MDV1_usr_bin_ or on station 2 in MDV1_.

In your SuperBASIC program you can get your home directory with:

Code: Select all

100 home$=GETENV$('HOME'):REMark case of environment variable 'HOME' must be preserved(!)
140 REMark home$ now holds 'MDV2_home_popopo_' and environment variables will NOT be cleared by new or clear(!)
180 mydata='Lorem ipsum...'
220 OPEN#4,home$&'myfile_dat'
260 PRINT#4,mydata
300 CLOSE#4
Now on your MDV2_ there should be the file:

home_popopo_myfile_dat

As you can see Pth_rext and env_bin are really small (about 2.5 KByte) and you can find them here:

https://dilwyn.theqlforum.com/tk/index.html

Environment Variables v1.07 (from C68 compiler) and Path (from Phil Borman). There is also Drivers.zip on this page with all drivers from Phil Borman (PTH, REDIRECT and SUB) which are all very useful (IMHO).

AND ONE BIG ERROR IN YOUR PROGRAM:

You are using:

Code: Select all

50 CheckF = 800 :      REMark Line for checking procedure
This is horror of horror(!):

You cannot RENUMber this program afterwards! The RENUM command does not check for variables which hold a line number. Try:

Code: Select all

RENUM;100,50


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
Derek_Stewart
Font of All Knowledge
Posts: 4610
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: COLON algorithm

Post by Derek_Stewart »

Hi,

The PTH device by Phil Borman, is one of the most useful extensions to QDOS, another of Phils' excellent extension is the SUB device, much better then DEV is SMSQ/E and works in QDOS.

But it would seem no one bothers to use it, there preference is to struggle on with an old version of QDOS that has documented bugs.


Regards,

Derek
User avatar
RalfR
QL Wafer Drive
Posts: 1151
Joined: Fri Jun 15, 2018 8:58 pm

Re: COLON algorithm

Post by RalfR »

Derek_Stewart wrote: Tue Jan 21, 2025 7:16 amBut it would seem no one bothers to use it
Here ;)


7000 4E75
User avatar
Andrew
Aurora
Posts: 992
Joined: Tue Jul 17, 2018 9:10 pm

Re: COLON algorithm

Post by Andrew »

Derek_Stewart wrote: Tue Jan 21, 2025 7:16 am But it would seem no one bothers to use it
I use it - it really is one of the most useful extensions.


swensont
Forum Moderator
Posts: 311
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: COLON algorithm

Post by swensont »

The PTH device has been in my boot program for over 30 years. Makes it easy to have executables in difference directories and still execute them without having to know where they exist.

Tim


User avatar
Popopo
Gold Card
Posts: 360
Joined: Wed Apr 07, 2021 10:37 am

Re: COLON algorithm

Post by Popopo »

ql_freak wrote: Tue Jan 21, 2025 12:16 am Hi,

I haven't tested your "colon" example, cause I do not need it and even don't know why it's needed on a multitasking operating system like QDOS (SMS...). Normally you switch on your QL and run your boot program, where you setup the directories of the PTH device and set the environment variables for all of your programs (a lot of programs now support environment variables, especially C programs compiled with C68 or GCC cross compiler and of course S*BASIC).

If you are using a BBQL with version before JS (extensions loaded in a SuperBASCIC program cannot be used in this program) you must split your boot program in 2 SuperBASIC programs (note: All programs only tested for syntax, I have not run them; i.e. they will load without MISTake):

.....
LRUN PTH1_myDoWhatIAmThinking_bas

and it will find it if it is on MDV1_, MDV1_bin_, MDV1_usr_bin_ or on station 2 in MDV1_.
.....

As you can see Pth_rext and env_bin are really small (about 2.5 KByte) and you can find them here:

https://dilwyn.theqlforum.com/tk/index.html

Environment Variables v1.07 (from C68 compiler) and Path (from Phil Borman). There is also Drivers.zip on this page with all drivers from Phil Borman (PTH, REDIRECT and SUB) which are all very useful (IMHO).

AND ONE BIG ERROR IN YOUR PROGRAM:

You are using:

Code: Select all

50 CheckF = 800 :      REMark Line for checking procedure
This is horror of horror(!):

You cannot RENUMber this program afterwards! The RENUM command does not check for variables which hold a line number. Try:

Code: Select all

RENUM;100,50
Hi :)

Well, now I will do a fast answer and tomorrow a detailed one.
In your examples... you need to know what is going to be loaded before to set it up.
What I am trying to show is that you can make a way to don't care from where you are.

Secondly, I understand your point of view of expert user. But you are not (perhaps) thinking in new people that are new in QL world and doesn't understand how it goes. As easy it is to start, much comfortable is the transition.

Thirdly, the idea was always to show that it is possible to load a software from any removable driver without knowing previously where it is inserted. The base code is only a pretty bad attend to show it.

Fourthly. It must be free of ROM versions or external tools.

5. line 800 is not an error in my program. Ugly yes, but not an error. I know that I must renum in a slot and not the whole code. It is just a fast prototype and demo. Nothing else. Of course it can be programmed better, but with my low skills nowadays, that is enough for a demo. I will make a compiled C version once I have time for it, and a more elegant basic code.

I prefer to use MRUN instead MERGE, but just I didn't know how to code a basic program without numbering the lines. Now that I know it, just need the time to do it.

Finally, thank you :) for all your advises and point of view. I will read it carefully ASAP. They will teach me very much.


User avatar
Popopo
Gold Card
Posts: 360
Joined: Wed Apr 07, 2021 10:37 am

Re: COLON algorithm

Post by Popopo »

tofro wrote: Mon Jan 20, 2025 3:44 pm Just a quick hint for a useful "hack":

Note you can totally MERGE a file with instructions, but no no line numbers in S*BASIC. If you do a MERGE "flp1_SETIT" and the file has the line "a = 12345" (just the BASIC instruction with no line number), the variable a will have the value 12345 after the MERGE.

This might be useful to avoid line number collisions in your program.
Yes, that is my intention.
As we talked before, I didn't know how to type a program without number lines without using external editor.
So what I decided to do (to make the job till then) is to use a number that the demo will not reach (always? smaller than this). So 800 was the first to come to my mind :)
I prefer to MERGE or MRUN to avoid precisely what you have mentioned, basic lines collision.


User avatar
Andrew
Aurora
Posts: 992
Joined: Tue Jul 17, 2018 9:10 pm

Re: COLON algorithm

Post by Andrew »

Popopo wrote: Tue Jan 21, 2025 11:38 pm Yes, that is my intention.
As we talked before, I didn't know how to type a program without number lines without using external editor.
So what I decided to do (to make the job till then) is to use a number that the demo will not reach (always? smaller than this). So 800 was the first to come to my mind :)
I prefer to MERGE or MRUN to avoid precisely what you have mentioned, basic lines collision.
Take care - this is what the SuperBasic Manual says:
MERGE
NOTE 1

Unfortunately, if you MERGE a file of direct commands (ie. a program file without line numbers), only the first line will be read and the file will be left open, making it impossible to change the disk/microdrive cartridge. Some compilers provide commands to ensure that the file is closed and all of the commands executed.

Minerva and Toolkit II close the file, but still only the first command is executed, unless the MERGE command is used from within a program (in which case, the whole of the command file is executed). SMS ensures that MERGE works in both of these circumstances.


User avatar
Popopo
Gold Card
Posts: 360
Joined: Wed Apr 07, 2021 10:37 am

Re: COLON algorithm

Post by Popopo »

Andrew wrote: Tue Jan 21, 2025 11:47 pm
Popopo wrote: Tue Jan 21, 2025 11:38 pm Yes, that is my intention.
As we talked before, I didn't know how to type a program without number lines without using external editor.
So what I decided to do (to make the job till then) is to use a number that the demo will not reach (always? smaller than this). So 800 was the first to come to my mind :)
I prefer to MERGE or MRUN to avoid precisely what you have mentioned, basic lines collision.
Take care - this is what the SuperBasic Manual says:
MERGE
NOTE 1

Unfortunately, if you MERGE a file of direct commands (ie. a program file without line numbers), only the first line will be read and the file will be left open, making it impossible to change the disk/microdrive cartridge. Some compilers provide commands to ensure that the file is closed and all of the commands executed.

Minerva and Toolkit II close the file, but still only the first command is executed, unless the MERGE command is used from within a program (in which case, the whole of the command file is executed). SMS ensures that MERGE works in both of these circumstances.
Right,
I considered it. The idea is only to add the token value to compare. Nothing else.
I am using this site: https://superbasic-manual.readthedocs.i ... /copy.html
So, it keeps opened... wauuuu... I didn't read anything about it. Thank you. how weird. A merge that doesn't close the second file.
Thank you

The info sometimes a little short, but that is amazing how it works and helps me to find easy some info for commands.


Post Reply