SBldr
                                 =====


    SBASIC Loader: EXecute SBASIC programs, with or without line numbers


Compatibility
=============

SMSQ//E + Qlib_run only

Ideally attached to FileInfo (see below)


Usage
=====

As an SMSQ/E user you will know that SBASIC source programs can be EXecuted
as well as RUN:

        EX ram1_myprog_bas

and

        EX 'ram1_myprog_sav'

or even just

        EX "ram1_myprog"

and it will execute either.

What EX (and other commands in the family like EXEC_W, etc) does is to start
an SBASIC daughter job and load and run the program as if it were a normal
independent executable. (Except that you can usually BREAK into it and then
do other interpreter stuff with it.)

However, in the first case, you cannot EXecute (or even RUN) a program
without line numbers; SAV files always have line numbers.

SBldr caters for three cases:

1) Standard S*BASIC source file with line numbers
2) Tokenised S*BASIC SAV file
3) Standard S*BASIC source file without line numbers

For source code without line numbers SBldr creates a temporary copy of the
line numberless file and executes that instead, and after EXecuting it
immediately deletes the temporary file again.

The temporary file is created in the same directory as the original so
that HOME_DIR$ will work as expected.

In cases 1) and 2) above, a quick test by SBldr determines whether the
source code is of that type and immediately EXecutes that program, so it
is almost as fast as if the code had been executed directly.

The point of SBldr is to make transparent the EXecution of SBASIC files
without having to think about what kind they are or whether they have line
numbers.

It could be used as follows:

        EX <path>SBldr; 'ram1_myprog_bas'

You can also add a command line to myprog if it requires one:

        EX <path>SBldr; 'ram1_myprog_bas; <command>'

Note that the command is within SBldr's command string!

You can also use SBldr without a parameter. It will then take its
instruction (file name & command line) from the stuffer buffer.

SBldr needs the file extension to be either bas or sav or it will return
an error.

However, none of the above is of much use apart from the ability to
execute line numberless source code. The real usefulness lies in attaching
it to FileInfo.


FileInfo
========

First of all, for ease and speed, load SBldr as a Thing in your boot file:

        ERT HOT_RES1("g",'win2_util_bas_SBldr_obj')

You don't need to use up a valuable key for this. If you arent going to use
SBldr on a hotkey, you could just as well do:

        ERT HOT_RES1(CHR$(0),'win2_util_bas_SBldr_obj')
        ERT HOT_REMV(CHR$(0)): REMark remove key reference again

Now SBldr will reside as a Thing in memory and wont have to be loaded from
disk on each use.

Create a new entry in the FileInfo database for the bas and sav
extensions. Check your FileInfo manual for how to do this if you don't
know. This only shows how to do it for FileInfo2 using the FI2
Configurator:

0. If it doesn't already exist create a new extension 'bas'
1. Create a new Action for bas. Call it EX or Execute
2. Make SBldr the Thing to launch if you made it a Thing as shown above,
   otherwise add SBldr's path and file name to the line
   Executable file to load.
3. Add the "full file name and extension" variable («devN_name_ext») and
   click Put it on the stack.

As some file managers wont EXecute a BAS or SAV file directly since they
arent files of type 1, it is worthwhile using the SBldr as intermediary.
So therefore do the same for the sav extension. Then save the database to
memory and to file before quitting the Configurator.

Now when clicking on the name of an S*BASIC source file in your favourite
FileInfo-complient file manager you should see an option to EXecute the
file.


Programming notes
=================

If you get a 'buffer overflow' error this may mean that an S*BASIC source
line exceeded 4096 characters. The obvious thing to do is to write tighter
code with shorter lines! If the problem occurs frequently you can change
the second line of SBldr's code to rem $$buff=<some value of your choice>
and recompile the program.

SBldr is rather simplistic. It doesn't do a lot of error checking for
malformed files and the like as these are usually exceedingly rare. Also
it depends on the correct extensions. After more than 10 years of use I
have personally never found the need for more rigorous error checking.

I rarely use HOME_FILE$ or HOME_CURR$ so I haven't looked into any
complications that could arise from executing a surrogate file.

SBldr is easy to compile with Turbo if required, but grows to a whopping
8k+! Watch out for string dimension sizes! You may have to replace CMD$
with OPTION_CMD$ and the Qlib directives with Turbo ones.

I forgot Id used this utility to illustrate the use of then new, or
under-used, commands in SBASIC. You can find more details on how this
and how this program works under Knoware/Articles/SBldr.
Note this version is not the same as the example given there!


Program Status
==============

V0.03, pjw, 2oi5
V0.04, pjw, 2025 Apr 19, Extra check on file, comments, tidy
                         er = FEX() is nonsense, so replaced with EX
                         er = FEW on intermediary file changed to EX

               Conditions of use and DISCLAIMER as per Knoware.no

Generated by QuickHTM, 2025 Apr 19