MDIR_BAS (v1.05) is a SuperBASIC program designed to facilitate using the MAKE_DIR keyword (FLP/RAM, [SUPER] GOLD CARD, QXL].
The MAKE_DIR keyword is used for creating sub_DIRectories — that is, subordinate DIRectories to the main directory. On the QL, these appear as names appended an arrow-type symbol ‘ ->’.
I have found that on some occasions (I think this is caused by using an older TURBO TOOLKIT), the MAKE_DIR command is ignored by my QL. This is corrected by re-invoking the TK2_EXTensions command.
If you do not yet have the MAKE_DIR keyword on your system, then you can modify the program for other purposes by having the appropriate DEFined PROCedures perform the tasks you want.
The SuperBASIC LISTing is not optimized; but, compiles easily.
A CPORTed {ANSI} version is also included for comparison for those interested in seeing how a functional ‘C’ program looks. I have not tried compiling the MDIR_c code, yet.
Using MDIR_BAS
MDIR_BAS uses the five function_keys and the Escape_key (to quit).
Simply press the appropriate function_key for the QDOS device on which you wish to MAKE_(a_sub_)DIR(ectory). The options are:
flp1_ ⇔ [F1] flp2_ ⇔ [F2] win1_ ⇔ [F3] win2_ ⇔ [F4] other ⇔ [F5]
Thus, if you want to make a sub_DIRectory on ‘flp1_’ you would press ‘F1’. You should see a flashing_cursor within a highlighted (green) strip which should correspond with the function_key that you pressed. INPUT the sub_DIRectory name.
If you INPUT “test” (for example), when you exit the program you should see the name “test ->” in the appropriate DIRectory.
If you INPUT a name longer than 10 characters, the menu window will reset. Use this feature to your advantage if you decide that you have selected the wrong storage device.
If you select ‘F5’ for ‘other’, you must input the DEVice name, including the underscore ‘_’.
Of course, press the ESCape_key if you want to exit the program.
There is no error_trapping in version 1.xx of the program. If you duplicate an existing filename, the program will halt.
(NOTE: MDIR_exe 2.xx has a duplicate name trap and accompanies all PLATYPUS Software programs).
Some thoughts about CPORT & MDIR_c
The ‘C’ programming language is very much ballyhooed as being the ideal vehicle for writing transportable source code that can then be compiled for different computer operating systems. I don’t know if this is true or not.
I have heard that ‘C’ is apparently a preferred programming language because most “computer science” students have to learn it, and that having gone to the effort, they are reluctant to abandon it. I don’t know if this is true or not, either.
I do know that because it is a mid-level language it does not have many of the amenities (i.e., keywords) found in BASIC.
I know that there had been many rudimentary concepts about the ‘C’ language that I did not grasp because I had relied quite heavily on various books which obviously presumed you knew things that I obviously did not!
The first was the ‘main()’ designation. Stating what is now the obvious, it is that portion of a SuperBASIC program that is not contained as PROCedures (presuming you are using PROCedures).
The next thing that is worth mentioning which seemed ‘strange’ was the structure and notation. Some time ago I ascertained that the ‘strange’ notation/structure is a byproduct of the language having been designed to be hand written, first, rather than on a terminal. Thus, REMarks are framed by “/* */”; each statement is written on a separate line; and, so on. When scribbled on a legal pad, the notation seems quite appropriate; and, almost logical.
So, I bought my copy of CPORT (Digital Precision) from Mechanical Affinity last Fall. It was expensive, but it was certainly no more expensive than a course on ‘C’ would have been; and in the end, there is nothing quite like having the benefit of a rosette stone to see how PROCedures and their statements translate directly to the ‘C’ language from SuperBASIC.
Now, my first attempts at using CPORT resulted in more ERRORs and WARNINGs than I would have thought.
Initially I was disappointed and frustrated by my first attempts because I use the TURBO compiler which is apparently more demanding than the LIBERATOR; and, certainly more demanding than interpreted SuperBASIC. I put the program away for several months since I had other things to do.
Well, I come from a long line of read-the-instructions-last users. This is not to say that I don’t read the instructions, but since I think the computer is supposed to make things easier, I especially think that most modern software should be relatively easy to use. Really good design, regardless of mode of expression, usually has a simple elegance underlying it.
One problem I encountered on my initial attempts to CPORT a program was using the INKEY$ keyword. Fortunately there are two, short, sample programs included with CPORT, one of which employs INKEY$!
My other problem involved slicing an array. This took more effort, and periodic thought over a six month period.
CPORT’s limitations are the SuperBASIC code that you give it to translate. GIGO, indeed!
The limitations of the ‘C’ language’s transportability should be obvious when you look at the number of statements which begin ‘SB_’ (SuperBASIC) suggesting that some massaging [as Bob Swoger likes to say] certainly needs to be done to the code if it is to be used on another computer platform.
Nonetheless, I hope the inclusion of the CPORTed code makes some aspects of the ‘C’ language less cryptic.
HAPPY TRAILS,
AND COMPUTING, TO YOU …
MDIR_bas
100 DIM BLANK$(24), Knot$(24), thi$(20), thi2$(15), F$(15), t$(3), dev$(24)
110 BLANK$ = " ": REMark 21 SPACES
120 Knot$ = "invalid QDOS device!"
130 F$ = "_FLIST_imp": t$ = "flp"
140 a = 1: POKE 163890, 0: MODE 0
150 Wt: Wz: Wo
160 FILE
170 DEFine PROCedure Wt: WINDOW#2, 512, 256, 0, 0: PAPER#2, 7: END DEFine
180 DEFine PROCedure Wz: WINDOW#0, 413, 10, 50, 241: PAPER#0, 7: INK#0, 2: END DEFine
190 DEFine PROCedure Wo: WINDOW 462, 250, 25, 3: PAPER 7: BORDER 1, 7: END DEFine
200 DEFine PROCedure Sound: BEEP 900, 20: PAUSE 5: BEEP 900, 40: END DEFine
210 DEFine PROCedure Noise: BEEP 2000, 20: END DEFine
220 DEFine PROCedure CheckKey
230 REPeat key
240 ke = CODE(INKEY$)
250 IF ke = 232 OR ke = 236 OR ke = 240 OR ke = 244 OR ke = 248 THEN EXIT key
260 IF ke<236 AND ke>27 THEN BEEP 900, 40: CheckKey
270 IF ke = 27 THEN Noise: PAUSE 10: Sound: Bye: EXIT key
280 END REPeat key
290 END DEFine
300 DEFine PROCedure FILE
310 d = 0: CSIZE 0, 0
320 WINDOW#1, 512, 256, 0, 0: PAPER#2, 7: INK#2, 0: CLS#2: INK 0
330 LINE 0, 96.5 TO 512, 96.5: LINE 0, 92 TO 512, 92: Noise
340 STRIP 7: INK 2: AT 1, 55: PRINT' @ PLATYPUS Software'
350 AT 1, 7: STRIP 0: INK 7: PRINT" DEVICE "
360 MAKER
370 END DEFine
380 DEFine PROCedure MAKER: d = 0
390 WINDOW#0, 124, 132, 42, 20
400 PAPER#0, 7: BORDER#0, 1, 0: CLS#0
410 AT#0, 0, 0: INK#0, 0
420 PRINT#0, " flp1_ = = [F1] "
430 PRINT#0, " flp2_ = = [F2] "
440 PRINT#0, " win1_ = = [F3] "
450 PRINT#0, " win2_ = = [F4] "
460 PRINT#0, " other = = [F5] "
470 STRIP#0, 2: INK#0, 7: PRINT#0, " MDIR 1.05z "
480 STRIP#0, 0: INK#0, 7: PRINT#0, BLANK$: INK#0, 0: STRIP#0, 7
490 CheckKey
500 YourChoice = ke
510 SELect ON YourChoice
520 = 232: AT#0, 1, 0: highlight: t$ = "flp": a = 1: dev$ = "flp1_": AT#0, 1, 0: INK#0, 0: PRINT#0, " ";dev$: AT#0, 1, 7: INPUT#0, thi$: MakeOne
530 = 236: AT#0, 3, 0: highlight: t$ = "flp": a = 2: dev$ = "flp2_": AT#0, 3, 0: INK#0, 0: PRINT#0, " ";dev$: AT#0, 3, 7: INPUT#0, thi$: MakeOne
540 = 240: AT#0, 5, 0: highlight: t$ = "win": a = 1: dev$ = "win1_": AT#0, 5, 0: INK#0, 0: PRINT#0, " ";dev$: AT#0, 5, 7: INPUT#0, thi$: MakeOne
550 = 244: AT#0, 7, 0: highlight: t$ = "win": a = 2: dev$ = "win2_": AT#0, 7, 0: INK#0, 0: PRINT#0, " ";dev$: AT#0, 7, 7: INPUT#0, thi$: MakeOne
560 = 248: AT#0, 9, 0: highlight: AT#0, 9, 0: INK#0, 7: PRINT#0, " >": INK#0, 0: AT#0, 9, 2: INPUT#0, thi$: MakeOTHER : REMark use CTRL ]
570 MAKER
580 END SELect
590 END DEFine FILE
600 DEFine PROCedure highlight: STRIP#0, 5: INK#0, 7: PRINT#0, BLANK$: END DEFine
610 DEFine PROCedure TooLong
620 IF LEN(thi$)>10 THEN Noise: MAKER: END IF
630 END DEFine
640 DEFine PROCedure MakeOne
650 TooLong
660 IF d = 1 THEN MAKER
670 IF LEN(thi$)< = 10 THEN MAKE_DIR dev$&thi$
680 Sound
690 MAKER
700 END DEFine
710 DEFine PROCedure MakeOTHER
720 IF thi$(5)<>"_" THEN Noise: AT#0, 9, 0: PRINT#0, Knot$: PAUSE 30: STRIP#0, 0: INK#0, 7: AT#0, 12, 0: PRINT#0, Knot$: INK#0, 0: Noise: PAUSE 30: MAKER
730 IF LEN(thi$)>15 THEN Noise: MAKER
740 IF thi$(5) = "_" THEN t$ = thi$(1 TO 3): a = thi$(4): thi2$ = thi$(6 TO LEN(thi$))
750 IF thi$(5) = "_" THEN MAKE_DIR t$&a&"_"&thi2$
760 Sound
770 MAKER
780 END DEFine
790 DEFine PROCedure Bye: CLS#2: INK#2, 2: AT#2, 17, 28: PRINT#2, " @ PLATYPUS Software ": END DEFine
MDIR_c
/*
* Program : MDIR_c
* Author : Al Feng
* Purpose : implement MAKE_DIR keyword
* CfiXed by CfiX "V4.03" 1995 Apr. 26 18:54:49
*/
#define prog_version "1.05z"
#include "Test_h"
#include <cport.h>
#define BLANK " "
#define Knot "invalid QDOS device!"
#define F "_FLIST_imp"
#define RN ""
#define d 0
#define BLANK_ab1 1
#define dev_ab1 1
#define F_ab1 1
#define Knot_ab1 1
#define RN_ab1 1
#define t_ab1 1
#define thi_ab1 1
#define thi2_ab1 1
#define u_ab1 1
float a;
float ke;
float YourChoice;
CP_FILE sb_channo[16];
char thi[20+1-thi_ab1+1];
char thi2[15+1-thi2_ab1+1];
char t[3+1-t_ab1+1];
char u[16+1-u_ab1+1];
char dev[24+1-dev_ab1+1];
void PROCedure main() { CP_Initialise();
/* *^* DIM stmt deleted - may need to reinitialise
array(s) */ /* DIM BLANK$(24), Knot$(24),
thi$(20), thi2$(15), F$(15), t$(3), dev$(24) */
/* 21 SPACES */
strcpy(t, "flp");
a = 1;
SB_Poke(163890, 0);
SB_Mode(0);
Wt();
Wz();
Wo();
FILE();
exit(0);
enddef
void PROCedure Wt() /*> 170 <*/
{
SB_Window(FNO(2), 512, 256, 0, 0);
SB_Paper(FNO(2), 7);
enddef
void PROCedure Wz() /*> 180 <*/
{
SB_Window(FNO(0), 413, 10, 50, 241);
SB_Paper(FNO(0), 7);
SB_Ink(FNO(0), 2);
enddef
void PROCedure Wo() /*> 190 <*/
{
SB_Window(FNO(1), 462, 250, 25, 3);
SB_Paper(FNO(1), 7);
SB_Border(1, 7);
enddef
void PROCedure Sound() /*> 200 <*/ {
SB_Beep(900, 20, 0, 0, 0, 0, 0, 0);
SB_Inkey(FNO(0), 5);
SB_Beep(900, 40, 0, 0, 0, 0, 0, 0);
enddef
void PROCedure Noise() /*> 210 <*/ {
SB_Beep(2000, 20, 0, 0, 0, 0, 0, 0);
enddef
void PROCedure CheckKey() /*> 220 <*/ {
while ( 1) {
/*> key <*/
ke = (float) (SB_Inkey(FNO(0), 1));
if (ke = = 232 || ke = = 236 || ke = = 240 || ke = =
244 || ke = =
248) {
break;
/*> key <*/
endif
if (ke < 236 && ke > 27) {
SB_Beep(900, 40, 0, 0, 0, 0, 0, 0);
CheckKey();
endif
if (ke = = 27) {
Noise();
SB_Inkey(FNO(0), 10); Sound();
Bye();
break;
/*> key <*/
endif
endwhile
enddef
void PROCedure FILE() /*> 300 <*/
{
SB_Csize(FNO(1), 0, 0);
SB_Window(FNO(1), 512, 256, 0, 0);
SB_Paper(FNO(2), 7);
SB_Ink(FNO(2), 0);
SB_Cls(FNO(2), 0);
SB_Ink(FNO(1), 0);
SB_Line(FNO(1), 0, 96.5, 512, 96.5);
SB_Line(FNO(1), 0, 92, 512, 92);
Noise();
SB_Strip(FNO(1), 7);
SB_Ink(FNO(1), 2);
SB_At(FNO(1), 1, 55);
fprintf(FNO(1), " @ PLATYPUS Softwaren");
SB_At(FNO(1), 1, 7);
SB_Strip(FNO(1), 0);
SB_Ink(FNO(1), 7);
fprintf(FNO(1), " DEVICE n");
MAKER();
enddef
void PROCedure MAKER() /*> 380 <*/
{
SB_Window(FNO(0), 124, 132, 42, 20);
SB_Paper(FNO(0), 7);
SB_Border(FNO(0), 1, 0);
SB_Cls(FNO(0), 0);
SB_At(FNO(0), 0, 0);
SB_Ink(FNO(0), 0);
fprintf(FNO(0), "n flp1_ = [F1] n");
fprintf(FNO(0), "n flp2_ = [F2] n");
fprintf(FNO(0), "n win1_ = [F3] n");
fprintf(FNO(0), "n win2_ = [F4] n");
fprintf(FNO(0), "n other = [F5] n");
SB_Strip(FNO(0), 2);
SB_Ink(FNO(0), 7);
fprintf(FNO(0), "n MDIR 1.05z n");
SB_Strip(FNO(0), 0);
SB_Ink(FNO(0), 7);
fprintf(FNO(0), "%sn", BLANK);
SB_Ink(FNO(0), 0);
SB_Strip(FNO(0), 7);
CheckKey();
YourChoice = ke;
switch ( YourChoice ) {
case 232 : SB_At(FNO(0), 1, 0);
highlight();
strcpy(t, "flp");
a = 1;
strcpy(dev, "flp1_");
SB_At(FNO(0), 1, 0);
SB_Ink(FNO(0), 0);
fprintf(FNO(0), " %sn" , dev);
SB_At(FNO(0), 1, 7);
SB_Input(FNO(0), "%sn", thi);
MakeOne();
break;
case 236 : SB_At(FNO(0), 3, 0);
highlight();
strcpy(t, "flp");
a = 2;
strcpy(dev, "flp2_");
SB_At(FNO(0), 3, 0);
SB_Ink(FNO(0), 0);
fprintf(FNO(0), " %sn" , dev);
SB_At(FNO(0), 3, 7);
SB_Input(FNO(0), "%sn", thi);
MakeOne();
break;
case 240 : SB_At(FNO(0), 5, 0);
highlight();
strcpy(t, "win");
a = 1;
strcpy(dev, "win1_");
SB_At(FNO(0), 5, 0);
SB_Ink(FNO(0), 0);
fprintf(FNO(0), " %sn" , dev);
SB_At(FNO(0), 5, 7);
SB_Input(FNO(0), "%sn", thi);
MakeOne();
break;
case 244 : SB_At(FNO(0), 7, 0);
highlight();
strcpy(t, "win");
a = 2;
strcpy(dev, "win2_");
SB_At(FNO(0), 7, 0);
SB_Ink(FNO(0), 0);
fprintf(FNO(0), " %sn" , dev);
SB_At(FNO(0), 7, 7);
SB_Input(FNO(0), "%sn", thi);
MakeOne();
break;
case 248 : SB_At(FNO(0), 9, 0);
highlight();
SB_At(FNO(0), 9, 0);
SB_Ink(FNO(0), 7);
fprintf(FNO(0), " ½n");
SB_Ink(FNO(0), 0);
SB_At(FNO(0), 9, 2);
SB_Input(FNO(0), "%sn", thi);
MakeOTHER();
MAKER();
break;
endswitch
enddef
void PROCedure highlight() /*> 600 <*/ {
SB_Strip(FNO(0), 5);
SB_Ink(FNO(0), 7);
fprintf(FNO(0), "%sn", BLANK);
enddef
void PROCedure TooLong() /*> 610 <*/ {
if (strlen(thi) > 10) {
Noise();
MAKER();
endif
enddef
void PROCedure MakeOne() /*> 640 <*/ {
char cp_strwk1[dflt_str_size]; TooLong();
if (d = = 1) {
MAKER();
endif
if (strlen(thi) < = 10) {
SB_Make_Dir(CP_Concat(cp_strwk1, dev,
thi));
endif
Sound();
MAKER();
enddef
void PROCedure MakeOTHER() /*> 710 <*/
{
char cp_strwk1[dflt_str_size];
char cp_strwk2[dflt_str_size];
char cp_strwk3[dflt_str_size];
char cp_strwk4[dflt_str_size];
if (thi[5-thi_ab1] ! = '_') {
Noise();
SB_At(FNO(0), 9, 0);
fprintf(FNO(0), "%sn", Knot);
SB_Inkey(FNO(0), 30);
SB_Strip(FNO(0), 0);
SB_Ink(FNO(0), 7);
SB_At(FNO(0), 12, 0);
fprintf(FNO(0), "%sn", Knot);
SB_Ink(FNO(0), 0);
Noise();
SB_Inkey(FNO(0), 30);
MAKER();
endif
if (strlen(thi) > 15) {
Noise();
MAKER();
endif
if (thi[5-thi_ab1] = = '_') {
CP_Slice(t, thi, 1-thi_ab1, 3-thi_ab1); a =
(float) (thi[4-thi_ab1]);
CP_Slice(thi2, thi, 6-thi_ab1, strlen(thi)-thi_ab1);
endif
if (thi[5-thi_ab1] = = '_') {
SB_Make_Dir(CP_Concat(cp_strwk4,
CP_Concat(cp_strwk3,
CP_Concat(cp_strwk2, t, ftoa(cp_strwk1, a)), "_"),
thi2)); endif
Sound();
MAKER();
enddef
void PROCedure Bye() /*> 790 <*/
{
SB_Cls(FNO(2), 0);
SB_Ink(FNO(2), 2);
SB_At(FNO(2), 17, 28);
fprintf(FNO(2), " @ PLATYPUS Software n");
enddef
/* Cport: Translation done, at 2840 statements per
minute. 0 errors and 0 warnings. */
MDIR_h
void Wt();
void Wz();
void Wo();
void Sound();
void Noise();
void CheckKey();
void FILE();
void MAKER();
void highlight();
void TooLong();
void MakeOne();
void MakeOTHER();
void Bye();