The Cable Column

See all articles from Update July 1989
Author(s): Bill Cable
Publication: Update Magazine
Pub Details: Update July 1989
Date: July 1989
Pages: 17-19

WOOD AND WIND COMPUTING
Bill Cable : RR 2 Box 92 : Cornish, NH 03745 : 603 675 2218

In the last Cable Column (April 89) I discussed how to program in ARCHIVE including a guide to using the built-in ARCHIVE editor. Please keep that article handy when entering the ARCHIVE programs described in this column. I have heard from several UPDATE readers who are indeed trying ARCHIVE for the first time. If anyone gets stumped feel free to send me a SASE with a brief description of your problem and I will try to help you. I will also try to cover problems or requests of general interest in this column.

ARCHIVE features

ARCHIVE has a language and like SUPERBASIC, you either have to write your own ARCHIVE programs or use programs others have written to benefit from its features. Why use ARCHIVE instead of SUPERBASIC? The ARCHIVE language is designed to handle information in both string and numeric form. It has powerful built in commands that are difficult to duplicate with SUPERBASIC. If you have applications that involve information handling such as address lists, financial records, index files of any sort you may find ARCHIVE to be the best language available on the QL for your application.

Besides its excellent language and built in editor it has an interesting feature that makes it stand apart from most databases. It stores its records exactly as they are instead of making them all the same length. This makes it very efficient in storing data. Most databases require you to specify the length of each field that makes up a record. This means you have to allow for the longest expected value. If you allow 20 characters for the city field in an address database then each record has 20 characters set aside for city name. If the average city length is 10 then half the space is wasted and if a city comes up that is 22 characters long it has to be truncated. ARCHIVE on the other hand, uses only the amount of space each city takes up. This expains why you can get 600 addresses with a complex 25 field address database on one cartridge. If all those fields had to have space alloted to them even if they were not used it would take 3 cartridges to hold them. This makes it possible to design your databases with enough fields to cover all situations needed.

The down side of using flexible length records is that you don’t know where your records are unless you have a pointer list to tell you where each one is. That is why ARCHIVE must have its opened files closed properly. If that is not done the pointer list may be incomplete and you will get the message ‘wrong file type’ when you try to access it. Its a matter of opinion whether having the flexible length records is worth the vulnerability. I would like ARCHIVE even if it didn’t have this unique feature. Careful backing up takes care of most of the vulnerability. People who get complacent about their software/hardware and don’t make backups are taking great risks no matter what machine they have and what software they use.

FILER – A progam for file handling in ARCHIVE

FILER is the name of a group of ARCHIVE procedures listed below which should help you with your ARCHIVE file tasks. It allows for easy copying, deleting, formatting from within ARCHIVE. Always be careful when formatting because anything already on what you format will be lost. Use FILER to back up your databases by making copies.

There is a lot of detail packed into the code that may not be clear at first. Notice how the ‘error’ statement is used to check for possible errors and protect the procedures from being halted by errors. I make use of the ARCHIVE screen reversing character, chr(26). Whenever you print chr(26) the screen will reverse ink,paper until you print chr(26) again. The only global variable is ans$ which I use to pass values back to calling procedures. The getkey() function allows for single key input much of the time. A lot of screen positioning is used to give the appearance of windows. The procedures box and get_device may be useful in your own programs. Box creates a cleared area on the screen in normal or reverse color. Get_device will prompt somewhere on the screen for a device and return its name in ans$. Look up unfamiliar commands and functions in your QL manual.

Type in FILER by starting ARCHIVE and entering the editor. After typing it in save it. You can run it by typing : run ‘{}filer'<ENTER> where {}=device or typing filer<ENTER> if it is already loaded. You can jump to FILER from a run statement in your own program and then jump back to your program from FILER. You can merge it with your own program. It should make backing up from within ARCHIVE easy for you. You must close your database before copying it. If you want to copy a file using the same name you can just press enter when prompted for the target name. In the listing below the bold is for emphasis.

proc box;line1,col1,line2,col2,reverse
local j
if reverse: print chr(26): endif : let j=line1
while j<line2+1: print at j,col1; tab col2;: let j=j+1: endwhile
if reverse: print chr(26): endif
endproc
proc do_copy;i$,j$
print at 20,52;"(doing copy now)";: backup i$ as j$
endproc
proc do_delete;i$
print at 23,52;"(deleteing "+i$;: kill i$
endproc
proc do_format;i$
print at 22,52;"(formatting "+i$+")";: format i$
endproc
proc do_run;i$,j$
print at 22,52;"(pr"+j$+" run "+i$+")";
if j$="g": run i$: else : run object i$: endif
endproc
proc err_check;l,c,m$
if errnum()
print at l,c;"Err = ";errnum(); at l+1,c;m$;" failed. Press <ENTER>";
input m$;: endif
endproc

proc filer
local sd$,td$,td$,tf$,c$,i$,j$
mode 0: while 1
cls : print at 0,29;"F I L E R";:p_26:get_device;2,20,"Which Device?"
if ans$="":p_26: cls : return : endif : let sd$=ans$: let c$="?"
print at 12,22;"(directory of "+sd$+")";
while c$<>"e":p_26: dir sd$:p_26
box;13,50,24,80,0: print at 13,51;"FILER MENU FOR ";upper(sd$);
print at 14,53;"c copy a file"
print at 15,53;"d delete a file"
print at 16,53;"g run a prg program "
print at 17,53;"o run a pro program"
print at 18,53;"f format medium in ";sd$;
print at 19,53;"e exit FILER MENU"
print at 20,51;"Press key : ";:p_26: print " ";
let c$=lower(getkey()): print c$;" ";:p_26
if c$="c":get_device;13,50,"Copy from "+sd$+" to where?": let td$=ans$
let sf$="?": while sf$<>"" and td$<>""
if sd$=td$:p_26: dir sd$:p_26: endif :box;13,50,23,80,0
print at 13,58;"FILE COPY";
print at 14,56;sd$;" to ";td$; at 16,52;"copy ";sd$;
input sf$: if sf$<>"": print at 18,52;"To ";td$;: input tf$;
if sd$<>td$ and tf$="": let tf$=sf$: print tf$: endif
if tf$<>"": error do_copy;sd$+sf$,td$+tf$:err_check;22,51,"Copy"
endif : endif : endwhile : endif
if c$="d"
print at 22,52;"Delete : ";sd$;: input sf$
if sf$<>"": error do_delete;sd$+sf$: endif : endif
if c$="g" or c$="o"
print at 21,52;"Run : ";sd$;: input sf$: if sf$<>""
error do_run;sd$+sf$,c$:err_check;23,52,"Run": endif : endif
if c$="f"
print at 20,51;"Format ";sd$;" - y/n : ";: input i$;: if lower(i$)="y"
input at 21,52;"Give a name : ";i$;
if i$<>"": error do_format;sd$+i$:err_check;23,51,"Format": endif
endif : endif : endwhile :p_26: endwhile
endproc
proc get_device;l,c,m$
local i$,j$
box;l,c,l+11,c+30,0: print at l,c+8;"DEVICE LIST";
print at l+2,c+3;"1. mdv1_ 5. ram1_"; at l+3,c+3;"2. mdv2_ 6. ram2_";
print at l+4,c+3;"3. flp1_ 7. Other"; at l+5,c+3;"4. flp2_ 8. Done";
print at l+7,c+1;m$;: let ans$=""
while ans$=""
print at l+8,c;rept(" ",30);
print at l+8,c+3;"Press key [1 to 8] : ";:p_26: print " ";
let i$=getkey(): print i$;" ";:p_26
if i$="1": let ans$="mdv1_": endif
if i$="2": let ans$="mdv2_": endif : if i$="3": let ans$="flp1_": endif
if i$="4": let ans$="flp2_": endif : if i$="5": let ans$="ram1_": endif
if i$="6": let ans$="ram2_": endif : if i$="8": let ans$="": return : endif
if i$="7": input at l+9,c+2;"Device name : ";j$;
if len(j$)=5: if j$(5)="_": let ans$=j$: endif : endif
if ans$=""
input at l+10,c+2;"Not a device [<ENTER>] : ";j$;
box;l+9,c,l+10,c+30,0: endif : endif
endwhile
endproc
proc p_26
print chr(26);
endproc
proc start
filer
endproc

WOOD AND WIND COMPUTING
Bill Cable : RR 2 Box 92 : Cornish, NH 03745 : 603 675 2218

Business and Educational Software for the QL

DBTutor : An ARCHIVE based learning shell. This program allows users to set up databases to learn any subjects they wish. It works well with any topic that can be typed in. Many interesting drills can be done to help learn the material including : flashcard, type in answer, reverse question and answer, score keeping, print missed questions, selected by subject, keys, or word occurence. Parents can set up drills for their children. Students can use it to learn languages or any school subject. QL users can use it to help learn computer related topics. The material can also be printed out in test or complete form. Long after the material has been entered it can be quickly reviewed. DBTutor uses the power of ARCHIVE without requiring the user to know anything about ARCHIVE. It is all menu driven. Comes with a detailed 25 page manual and many sample databases. I have a version that works very well on unexpanded QLs also. Order directy or send SASE for a list of other software available. (5 1/4 DSDD disk $24.95 or 2 MDV $28.95)

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.