COLON algorithm

Anything QL Software or Programming Related.
User avatar
pjw
QL Wafer Drive
Posts: 1592
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: COLON algorithm

Post by pjw »

Andrew wrote: Sun Jan 19, 2025 11:59 pm <>
5. For compiled programs: use Config Blocks
(Popopo, you can read about Level 1 and Level 2 config blocks here: https://dilwyn.theqlforum.com/docs/asm/index.html )

In my opinion the best thing for QL world is to have some standardisation across all the platforms.
Config Blocks and Execute Parameters are useful in many other ways, not only to get the program's directory.
So the best thing would be to also have a Home_Thing for QDOS.
But even under SMSQ/E the Home Thing doesnt always work. For example if you load a compiled program as a Thing, with HOT_RES, etc, then there is no home directory. Therefore, I always offer the possibility of configuring the home directory using a standard config item.

The simplest case is if only a single config item is needed, then one can insert the config block directly in the S*BASIC source code. The block could look like this:
click to view!
click to view!
If more than one config item is wanted then a toolkit is needed which must be compiled with the code. Such a toolkit can be found at Dilwyn's.

To create the config block illustrated, you could do worse than use this ugly piece of code below:

Code: Select all

100 rem                 MakeConfig_bas ©PWITTE April 24th 1995
110 rem             Make a simple config block of type Qjump level 01
120 rem              for inclusion in a compiled SuperBASIC program
130 :
140 rem The following is the data that is produced:
150 rem       dc.b '<<QCFX>>01'                     ;Config header
160 rem       dc.w pl%,progname$                    ;Name of program
170 rem       dc.w vl%,version$                     ;Program version
180 rem       dc.b 0,key$                           ;Selection key for this item
190 rem       dc.w string-*                         ;Relative offset to item
200 rem       dc.w 0                                ;Ptr to pre- and post
210 rem       dc.w 0                                ; processing routines
220 rem       dc.w description-*                    ;Point to description
230 rem       dc.w attr-*                           ;Point to attributes
240 rem       dc.w -1                               ;End marker
250 rem attribute                                   ;Only one attribute here:
260 rem       dc.w attr%                            ; if 0 strip trailing spaces
270 rem description
280 rem       dc.w dl%,description$
290 rem string
300 rem       dc.w max%                             ;Max allowable length (incl lf)
310 rem       dc.w sl%,dstring$ + spare room        ; plus room up to max length
320 :
330 estrg$='Avoid string lengths of 10,34 and above 64'
340 zw$=chr$(0)&chr$(0):e$=chr$(255)&chr$(255)     :rem Word constants: 0,-1
350 n$='ram1_cfg_bas':cls:input'Output to (eg '&n$&')'!fnm$:if fnm$='':fnm$=n$
360 print \estrg$\'Enter:'                         :rem Get user settings
370 progname$=GetStrg$('the name of your program, eg Myprog')
380 version$=GetStrg$('version number, eg 1.04')
390 description$=GetStrg$('description of item to configure')
400 dstring$=GetStrg$('the default item string')
410 rep loop
420  input'max allowable length of item string'!max%
430  if max%<len(dstring$)-1:max%=len(dstring$)-1:print'Adjusted to'!max%
440  if max%<>10 and max%<>34 and max%<65:exit loop
450  print estrg$
460 endrep loop
470 print\'Press the selection key for this item ';:k%=code(inkey$(-1))
480 if k%>96 and k%<123:k%=k%-32:endif:key$=chr$(k%):print key$
490 print'Are trailing spaces to be stripped? <Y/n> ';:at$=inkey$(-1)
500 if at$ instr 'y'&chr$(10):attr%=0:print'Y':else:attr%=1:print'N'
510 oa%=4 : od%=8 : os%=14+len(description$)       :rem Calculate offsets
520 line$='11 Config$="<<QCFX>>01'                 :rem Build config block string:
530 line$=line$&progname$&version$                 :rem  as shown in
540 line$=line$&chr$(0)&key$                       :rem  assembler above
550 line$=line$&Int$(os%+2*(os%=34))               :rem Work around awkward value
560 line$=line$&zw$&zw$&Int$(od%)&Int$(oa%)&e$
570 line$=line$&Int$(attr%)&description$
580 if os%=34:line$=line$&zw$                      :rem Workaround filler bytes
590 line$=line$&Int$(max%):ip%=len(line$)-10       :rem Position of config item
600 line$=line$&dstring$                           :rem The default string
610 line$=line$&fill$(" ",max%-len(dstring$)+2)    :rem Room for max string + lf
620 line$=line$&'"'                                :rem End of SuperBASIC string
630 open_new#3;fnm$:print#3;line$                  :rem Write config block
640 print#3;'13 Config$=Config$(';ip%+1!'to'!ip%;'+code(Config$(';ip%;')))'
650 close                                          :rem Line 13 is to find the
660 :                                              :rem  string within the program
670 deffn GetStrg$(tx$)
680 loc l%,s$,loop
690 rep loop
700  input (tx$)!s$:l%=len(s$)
710  if l%<>34 and l%<>10 and l%<65:exit loop      :rem Mustn't have quotes &
720  print estrg$                                  :rem  linefeeds in a SB string!
730 endrep loop
740 ret Int$(l%)&s$&fill$(' ',l% mod 2)            :rem Convert to internal format
750 enddef                                         :rem  padding odd lengthed strgs
760 :                                              :rem Integer to internal format
770 deffn Int$(i%):ret chr$(i% div 256)&chr$(i% mod 256):enddef
780 :
LRUN it in a BASIC console and answer the prompts. This creates the necessary code, which you can merge into your program. More details can be found at www.Knoware.no/htm/utils.htm MkConfig.

The remainig logic on whether to use the configured home directory or the actual one depends on the application.


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
User avatar
Popopo
Gold Card
Posts: 360
Joined: Wed Apr 07, 2021 10:37 am

Re: COLON algorithm

Post by Popopo »

Mark Swift wrote: Sun Jan 19, 2025 10:23 pm

Code: Select all

REMark --- Install the BASIC extension 'HOMED_POC$' ---
F$=HOMED_POC$
IF F$="" THEN R=RESPR(180):P=R
IF P<>0 THEN FOR i=0 TO 15:C="067250000012052121000000001016078146078117000000"(i*3+1 TO i*3+3):POKE P,C:P=P+1:END FOR i
 ...
IF R<>0 THEN CALL R:CLEAR
PRINT HOMED_POC$
Very interesting,
I cannot manage to undestand all the concept since I need to get more info.
But I have read already that it is possible to create basic code without numbering the lines what force to run them inmediately when merging it or loading. OK.
But what I don't know is how to tell to the QL editor how to do it.
with ED or EDIT commands. All forces me to add numbers to each line.

Without using an external editor (from my PC), is it possible to do into the QL? Or do a need another tool?
Thanks


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 »

Andrew wrote: Sun Jan 19, 2025 11:59 pm 5. For compiled programs: use Config Blocks
(Popopo, you can read about Level 1 and Level 2 config blocks here: https://dilwyn.theqlforum.com/docs/asm/index.html )
Config blocks aren't limited to compiled programs or programs in machine code - You can use them in interpreted S*Basic programs as well. Tools to support this can be found here: https://ia801404.us.archive.org/0/items ... index.html

And, in my personal opinion, config blocks are even better than the HOME Thing.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Andrew
Aurora
Posts: 992
Joined: Tue Jul 17, 2018 9:10 pm

Re: COLON algorithm

Post by Andrew »

tofro wrote: Mon Jan 20, 2025 12:58 am Config blocks aren't limited to compiled programs or programs in machine code - You can use them in interpreted S*Basic programs as well. Tools to support this can be found here: https://ia801404.us.archive.org/0/items ... index.html
I didn't knew that! I learned something new today!


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

Re: COLON algorithm

Post by swensont »

Popopo,

There are a couple of tools that will allow you to write SuperBasic programs with no line numbers. "Basic Linker" is one. The other is "Structured SuperBasic". SSB can be found here:

http://swensont.epizy.com/ssb272.zip

With documentation in a PDF here:

http://swensont.epizy.com/SSB.pdf

Tim


User avatar
bwinkel67
QL Wafer Drive
Posts: 1500
Joined: Thu Oct 03, 2019 2:09 am

Re: COLON algorithm

Post by bwinkel67 »

Popopo wrote: Mon Jan 20, 2025 12:57 am Without using an external editor (from my PC), is it possible to do into the QL? Or do a need another tool?
Thanks
There are a bunch of editors on the QL that you can use. Heck, you could even use Quill and export as text file. I prefer Jan Bredenbeek's QED, which, in my opinion, is the best. You can find it on Dilwyn's site. It seems to follow the Amiga's ED key sequences.

However, for bigger things I prefer to use a PC text editor (I personally prefer Notepad) and just use an emulator to stick it into an MDV file and then read it via vDrive. That's about the easiest way.


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 »

bwinkel67 wrote: Sun Jan 19, 2025 10:44 pm
Popopo wrote: Sun Jan 19, 2025 10:20 pm
Derek_Stewart wrote: Sun Jan 19, 2025 9:34 pm I only use Minerva or SMSQ/E anything else does allow multitasking Basic.
This is a naive question but since I have no idea... is there any ROM that is not multitasking for QL?.
It is interesting because perhaps I will implement some multitasking parts of the demo and If there is a ROM or QL that is not multitasking, then won't be useful for me.
In QDOS, SuperBASIC can't multitask, you only have one instance. In other ROMs you could have multiple non-compiled SuperBASIC programs running.
Minerva is QDOS based and supports Multitasking Superbasic


Regards,

Derek
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

Use a text editor, like QED to write your program withou line number and save.

Then LRUN <program> will run the program.

When I use to use QDOS: JS or Minerva, I used numberless boot program to start the system up and not have the boot file retained in memory.

I ran a BBS on a QL with Minerva launching all the executable files with Multibasic.

I do not use the HOME thing, it is not required by me.


Regards,

Derek
User avatar
bwinkel67
QL Wafer Drive
Posts: 1500
Joined: Thu Oct 03, 2019 2:09 am

Re: COLON algorithm

Post by bwinkel67 »

Derek_Stewart wrote: Mon Jan 20, 2025 7:03 am Minerva is QDOS based and supports Multitasking Superbasic
I think it's easier, for clarity, when referring to QDOS, to focus on the original Sinclair released versions. Minerva and SMSQ/E are reimplemented QDOS compatible operating systems. The differnece between Minerva and SMSQ/E is that the latter won't run on a BBQL.


User avatar
pjw
QL Wafer Drive
Posts: 1592
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: COLON algorithm

Post by pjw »

Andrew wrote: Mon Jan 20, 2025 1:13 am
tofro wrote: Mon Jan 20, 2025 12:58 am Config blocks aren't limited to compiled programs or programs in machine code - You can use them in interpreted S*Basic programs as well. Tools to support this can be found here: https://ia801404.us.archive.org/0/items ... index.html
I didn't knew that! I learned something new today!
The MkConfig lines above allow you to configure the S*BASIC source directly. However, in that case one has to ensure that the config block (the bit starting with <<QCFX>>) is aligned to an even offset on the line it is on. The compiled code is always properly aligned.


Per
I love long walks, especially when they are taken by people who annoy me.
- Fred Allen
Post Reply