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.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.
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:
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 :
The remainig logic on whether to use the configured home directory or the actual one depends on the application.