Id like to draw attention to some otherwise under-documented keywords in SMSQ/E (you have to dig around the SMSQ/E source code documentation to find any mention of them), namely FEX, FEW, FET, FEP, EX_M, FEX_M and QUIT <error>. The first few are the function equivalents of procedures EXEC / EX, EXEC_W / EW, ET and EXEP, respectively. EX_M and FEX_M have no equivalents. QUIT now also takes a parameter, which can be any long word, eg an error code, and pass it back to the calling program. The parameters are the same as for the original procedures, so I wont bother you with the details here. The functions all return the ID of the (first) job executed, eg
jid = FEX_M(my_little_job;<command string>): SPJOB jid, 1
..or in the case of the W variants, 0 or any errors returned from that job. EX_M and its function equivalent FEX_M are identical to EX and FEX, except that the job started with EX_M/FEX_M is owned by the caller , although it returns, and not by the system, as is the case with the other non-W commands. (I guess that is what the _M stands for: Mine). So heres a utility I use, to give a taster:
If you use an editor to code S*Basic, line numbers tend to get in the way, so you do away with them during editing. Once the program is ready to be tested the line numbers have to go back in, or the program wont load or execute. Of course, if you use QD as your editor, you will no doubt enjoy the convenience of the SBAS/QD Thing; execute the program from within QD at the press of a button - no line numbers required. However, if you later want to check on one of these line numberless programs, you'll have to load and run them in QD, or find some some way of putting the line numbers back before running or executing the program. Under SuperBasic and Minerva Basic you could use AUTO as the first line, IIRC. Sadly, this doesnt work in SBasic.
So, wouldnt it be a lot more convenient to execute numberless programs directly? Here is one solution, or rather a palliative. SBldr [SBasic LoaDeR] makes it possible to use FileInfo2, EXEP and EX (and siblings) to execute (most of) these programs directly, as if they were normal jobs.
Yet reams of listings arent as much fun as they used to be, so I have tried to keep this fully functional demo terse. Any finesse (like error trapping, scanning the stuffer buffer, or ..) is left as an exercise for the avid coder. In plaintext, here is more or less what it does:
You could compile this program or use it as it is. Here are a few suggestions on how it could be deployed.
Lets start with the EX family, just to make things clear:
er = FEW(<path>SBldr_obj; " <target program name>; <target program command line>"
(Of course, any error returned in er could come from SBldr as well as the target program). Note that the trick to pass a command line through SBldr to the target program involves wrapping it into SBldr's command string.
In the FileInfo2 configurator, you can associate SBldr_obj with the _bas extension. Just make sure <devN_name_ext> gets on the stack.
Finally, it can usefully be put on a hotkey. While its easy enough to run the program youre editing directly from QD, often it is useful to be able to move around your source file and have the program running at the same time. With SBldr on a hotkey, just save your source file so its file name goes to the stuffer buffer, press your hotkey, and presto! your program is running - or not. You could do worse than:
ERT HOT_RES1(<key>, "<path>SBldr_obj", "SBldr")
There is a danger here, in that a momentary confusion may cause you to execute, instead of the program you intended, one you were hurridly side tracked into editing and saving a moment ago (but had no intention EVER of using on a live system, as it was merely a demonstration of a recursive delete routine applied to your main hard drive!) While that was in the realm of worst case scenarios, remember: mishaps come in all sizes. You cant see the name in the stuffer buffer, so that makes it vulnerable.
A copy of the code and executable can be downloaded here
As usual, comments and suggestions are welcome, though not expected (unless Ive made MISTates).
10 REMark $$chan=4 11 : 12 REMark + ---------------------------------------------------- + 13 REMark |< SBasic LoaDeR >| 14 REMark + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 15 REMark | Executes SBASIC programs | 16 REMark | Adds line numbers to numberless code via intermed- | 17 REMark | iary file in the same directory, for the sake of | 18 REMark | HOME_DIR$ &al. | 19 REMark | Add to FileInfo2 & Hotkey, or use with EX: | 20 REMark | | 21 REMark | er = FEW(<SBldr>;"<program>_bas [;<command_line>]") | 22 REMark | | 23 REMark | <SBldr> passes optional <command_line> to <program> | 24 REMark | | 25 REMark | Version 0.03, pjw, 2oi5, SBASIC only! | 26 REMark + ---------------------------------------------------- + 27 : 28 l% = LEN(CMD$) 29 IF l% = 0 THEN 30 fnm$ = HOT_GETSTUFF$: l% = LEN(fnm$) 31 ELSE 32 fnm$ = CMD$ 33 END IF 34 IF l% < 7: Bye -12 35 : 36 com$= '' 37 s% = ';' INSTR fnm$: REMark Additional command line? 38 IF s% THEN 39 IF s% < l%: com$ = fnm$(s% + 1 TO l%) 40 l% = s% - 1: fnm$ = fnm$(1 TO l%) 41 END IF 42 : 43 IF fnm$(l% - 2 TO l%) == 'sav': Bye FEX(fnm$; com$) 44 : 45 IF NOT fnm$(l% - 2 TO l%) == 'bas': Bye -15 46 ci = FOP_IN(fnm$): IF ci < 0: Bye ci 47 : 48 INPUT#ci; l$ 49 IF l$(1) INSTR '123456789' THEN 50 CLOSE#ci 51 Bye FEX(fnm$; com$) 52 END IF 53 : 54 co = FOP_DIR(fnm$): IF co < 0: Bye co 55 nm$ = fnm$(LEN(FNAME$(#co)) + 7 TO l%) 56 CLOSE#co 57 fnm$ = fnm$(1 TO l% - LEN(nm$)) & '#' & nm$ 58 IF LEN(fnm$) > 41: Bye -12 59 : 60 co = FOP_OVER(fnm$): IF co < 0: Bye co 61 BPUT#co; 49, 32, l$, 10 62 FOR i% = 2 TO 32767 63 IF EOF(#ci): EXIT i% 64 i$ = i% 65 INPUT#ci; l$: BPUT#co; i$, 32, l$, 10 66 END FOR i% 67 CLOSE#co: CLOSE#ci 68 : 69 er = FEW(fnm$; com$) 70 DELETE fnm$ 71 Bye er 72 : 73 DEFine PROCedure Bye(er) 74 IF er < 0: BEEP 3000,255 75 QUIT er 76 END DEFine Bye 77 :