Re: QD vB.07
Posted: Thu Aug 06, 2020 5:23 pm
Probably just pissing in the wind here, as usual, but..Derek_Stewart wrote:<>But with regards to compiling with Fileinfo2, I think a possible approach is:
Start SBASIC
Load basic programme to be compiled
Create Qliberator work file by LIBERATE dev_filename_ext
quit SBASIC
EX qlib_obj;"dev_filename_ext -OBJ dev_filename"
My first attempt at this did not work.
Code: Select all
10 rem $$chan=4
11 :
12 rem + ---------------------------------------------------- +
13 rem |< SBasic to Obj >|
14 rem + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
15 rem | Converts SBasic programs to a Q_Liberator object |
16 rem | file using the QLib compiler |
17 rem | |
18 rem | Adds line numbers to numberless code via intermed- |
19 rem | iary file in a temporary directory |
20 rem | |
21 rem | Add to FileInfo2, Hotkey, or use with EX: |
22 rem | |
23 rem | er = FEW(<sb2obj>;"<program>_bas [;<command_line>]") |
24 rem | |
25 rem | sb2obj passes the optional <command_line> to QLib |
26 rem | Use this to supply standard QLib cmdl parameters |
27 rem | (see Q_Liberator manual), except the file name. |
28 rem | |
29 rem | Version 1.02, pjw, 2oi5, SBASIC only! |
30 rem + ---------------------------------------------------- +
31 :
32 rem Config:
33 qlb$ = 'win2_bas_qlib_qlib_obj': rem QLib
34 out$ = '': rem Default output = input directory
35 tmp$ = 'ram1_sbhtmxxx': rem Location and name of temp file
36 first% = 1: step% = 1: rem First line and step size
37 :
38 rem Get input file name
39 rem Get it either from cmdl or from Stufferbuffer
40 l% = LEN(CMD$)
41 IF l% = 0 THEN
42 fnm$ = HOT_GETSTUFF$: l% = LEN(fnm$)
43 ELSE
44 fnm$ = CMD$
45 END IF
46 IF l% < 9: Bye -12
47 :
48 rem Process command line(s)
49 com$= ''
50 rem Additional command line?
51 s% = ';' INSTR fnm$
52 IF s% THEN
53 IF s% < l%: com$ = fnm$(s% + 1 TO l%)
54 l% = s% - 1: fnm$ = fnm$(1 TO l%)
55 END IF
56 :
57 :
58 rem Extract name and dir from file name
59 ci = FOP_DIR(fnm$): IF ci < 0: Bye ci
60 dir$ = FNAME$(#ci): CLOSE#ci
61 ci = FOP_IN(fnm$): IF ci < 0: Bye ci
62 ld% = LEN(dir$)
63 IF out$ = '' THEN
64 out$ = fnm$(1 TO 5) & dir$
65 IF ld%: out$ = out$ & '_'
66 END IF
67 nm$ = fnm$(6 + (ld% > 0) + ld% TO l% - 4)
68 :
69 rem Filter by extension
70 IF fnm$(l% - 2 TO l%) == 'sav' THEN
71 rem _sav files pass straight through
72 bas = 0
73 CLOSE#ci
74 ELSE
75 rem _bas file w/wo line number
76 IF fnm$(l% - 2 TO l%) == 'bas' THEN
77 bas = 1
78 ELSE
79 rem Wrong file type
80 Bye -15
81 END IF
82 :
83 rem Line numbers or not?
84 INPUT#ci; l$
85 IF NOT l$(1) INSTR '123456789' THEN
86 :
87 rem Process line numberless file
88 fnm$ = tmp$ & '_bas'
89 co = FOP_OVER(fnm$): IF co < 0: Bye co
90 bas = 2: i% = first%: lno$ = i%
91 BPUT#co; lno$, 32, l$, 10: rem First line
92 :
93 FOR i% = first% + step% TO 32767 STEP step%
94 IF EOF(#ci): EXIT i%
95 INPUT#ci; l$: lno$ = i%
96 BPUT#co; lno$, 32, l$, 10
97 END FOR i%
98 CLOSE#co
99 END IF
100 CLOSE#ci
101 :
102 rem Process non-sav files
103 rem Use SBasic daughter to tokenise program
104 pip$ = 'pipe_p' & HEX$(JOBID, 32)
105 co = FOPEN(pip$ & 'o_2048'): IF co < 0: Bye co
106 :
107 rem Slave will take instructions from here
108 cm$ = 'ci = fop_in(#0; "' & pip$ & 'o")'
109 :
110 rem Plumb in to SBASIC Thing
111 EXEP 'SBASIC'; cm$
112 :
113 rem Tell it what we want
114 PRINT#co; 'load "' & fnm$ & '"'
115 PRINT#co; 'qsave_o "' & tmp$ & '"'
116 PRINT#co; 'beep 2000,2': rem Signal success
117 PRINT#co; 'quit': rem Job done! Get rid of slave
118 fnm$ = tmp$ & '_sav'
119 END IF
120 :
121 rem Create QLib command line
122 com$ = fnm$ & ' -OBJ ' & out$ & nm$ & ' -NAME ' & nm$ &' '& com$
123 IF bas = 2: com$ = com$ & ' -NOLINE'
124 :
125 rem Compile!
126 Bye FEW(qlb$; com$)
127 :
128 rem Tidy and quit
129 DEFine PROCedure Bye(er)
130 IF er < 0: BEEP 2000,200: ELSE : BEEP 2000, 2
131 :
132 rem Remove any temporary files
133 IF bas: DELETE fnm$
134 IF bas = 2: DELETE tmp$ & '_bas'
135 QUIT er
136 END DEFine Bye
137 :