The concept of a Completely Interactive Database System (CIDS) that has been implemented on a micro-computer is interesting in that this type of environment is normally only found on mainframe computers. What I hope to do is cover the various aspects of implementing just such a system in the next few issues.
CIDS was created to make various kinds of data easier to work with, although ease of use has its problems, as we will discover. It may not be super duper fast, but it’s fast enough. It may not hold as much data as some programs, but it holds enough. What’s more, is that it can do more with the data than other programs of a similar nature. (By the way, there aren’t many.) CIDS files aren’t totally flexible, but they are flexible. For example, try defining graphic characters with a word processor. You’ll find it more challenging than you thought! With CIDS it’s much easier. CIDS will meet many of your personal needs, but it isn’t going to run a business without some help from you.
These ‘problems’ are not evident when using the CIDS program. CIDS most important ability is its apparent understanding of English commands. The most significant feature incorporated into CIDS is its ability to expand. You definitely will not find this feature in many programs. Integrated software is totally different. This too will be elucidated on as we progress through the CIDS environment.
CIDS Part 1
Type listing one into your computer. Make sure you type it in exactly as shown. Do not change line numbers, add or delete lines. Take your time and do it right. When your done save the program to tape.
The first thing we must do is initialize the variables that we will use and the dictionary of commands CIDS will use. This is accomplished in line 10. This line calls the initilization routine starting at line 9010 and ending at line 9040 with a RETURN statment.
By having the initializatiion at the end of the listing, the computer only has to execute it once. You must remember that when your computer encounters a GOTO or a GOSUB, it starts at the first line of the program and checks each and every line number until it finds a match. So, for example, if you have fifty lines of code at the beginning of your program that asks for names, numbers or other data and the core of the program that works on this data well below that; every time you tell the computer to GOTO the main part of the program it must check all those lines you put at the top. The computer has to look for the line using brute force; it doesn’t have ESP. If you are looking for a word in a dictionary, do you just automatically perceive the page and line number? I think not; you have to look for it by flipping through the pages. Burying the code in this manner will speed up the program execution. Whole articles can be written on this topic alone, But it is sufficient for us to realize that least used code goes further down in the program.
CIDS is a long program. This installment deals with just the startup routine. Other sections that will surface shortly are the full screen editor and the ADTO routine, each of which are significant in their own right. Long programs usually have several things to do and so, naturally, need several variables. Be sure to follow along closely.
A list of all the variables used so far can be found at the end of this article. Keep it handy. You will also find an annotated listing. Within the article we will go over in detail the operation of each routine as it appears in the program.
The first line of the initialization routine is 9010. This line is the one that sets up the variables that are necssary for CIDS to operate on a simple level. Essentially, it DIMs a large three dimensional array, and also defines three variables mf, ml and mc to keep track of the number of files (mf), the number of lines allowed in a file (ml) and the number of characters allowed in each line (mc). The next statement sets up a two dimensional array that is the same as the number of lines and characters allowed in a single file. You will use this array to store files that are deleted. That way you wish to have the file back,then it is stored away.
The ninth statement defines the variable g. G keeps track of the file with which you are currently working. The variable f keeps track of the number of files that are currently used.
The next statement DIMs the array d$. This is be our dictionary of commands that CIDS understands and the line numbers where the routines begin. Also defined are some variables that are used for different things at different times. The string variable a$ holds the commands that are entered.
Lines 9020, 9025, and 9030 fill up the array d$ with the various routines that CIDS performs. It is important that these lines are entered correctly or program control will most likely send you to unpredictable places. This area of the program will also tell you the beginning line number of each routine. This handy system turns out to be self documentation.
When I first conceived CIDS, I utilized a menu driven routine in which you typed in the name of the routine you wished to access. Since this was cumbersome, I changed to this approach, which is infinitely easier to use. If you think the adto command should be named edit, just change d$(7) to “edit5000.” Be sure that if you do decide to alter the names of any of the routines that you truncate them to only the first four letters as in d$(6).
The dictionary is what gives CIDS its ability to expand. If you write a routine to replace an existing one, then change the dictionary entry name and viola, your new routine is implemented. It could POKE values into memory locations or define graphic characters. The possibilities are endless. Remove routines and get more memory for data.
Now, with variables initialized, we RETURN to line 10 statement 2, which sends us to another subroutine at line 1506. Now, if you take a quick look at line 9020 statement 3 you will see:
LET d$(17)="help1506"
This subroutine (help) displays the command content of d$. After the commands have been displayed, we RETURN to line 10 statement 3. We then go to line 105 from which we go sub the input routine. The input routine is between lines 200 and 290. This routine is essentially an INPUT and string slice subroutine that can be called from anywhere in the program. Imagine never having to write another input routine! It accepts input (in a$) from the keyboard, looks for the first space and slices the word out. The sliced word is then stored in the variable w$(for word$). Nifty eh?
After we slice out the word, we do some error detecting to make sure that no bad things get through. We then RETURN to line 105. We then call yet another subroutine at line 400. This routine then takes the word sliced out of a$ and compares it with the dictonary that we set up in lines 9020 through 9030. If a match is found,then we hop out of the loop and go to the subroutine specified by the last four characters of the dictionary entry. When we finish the subroutine, we make a check to see if the first character of a$ is a comma. If it is, we slice it out and go back to the subroutine that we just came back from. If the first character of a$ is not a comma we simply RETURN. Since the routine was called from line 105 statement 2, we continue where we left off.
This brings us to the BEEP statment. After that, we go back to the first statement,and the whole process starts all over again. We are all done. Fini!
Now that you have the first part of the CIDS program, it is time to go over the first two commands and the screen color change routine. The first one will clear the screen and the second one will display on the screen the names of the commands that CIDS is currently using. The color adjust routine will change the screen to any color you wish.
Let’s start with the simplest routine; the clear screen routine. Look at line 9010 statement 2. You will see:
LET d$(4)="clea1506"
Clea is the name of the routine. 1506 is the line number it begins execution. Well, if you take a look at line 1506 you will see:
1506 CLS: RETURN
Now, when you are prompted for input and you say something like, “please clear the screen of all this trash,” CIDS will eventually locate the word clear. CIDS will then go through the dictionary and find the word clea. Then CIDS will hop over to the subroutine specified by the last four characters of the dictionary entry. Your screen is cleared.
The next routine is not a command, but instead a routine to change the screen color. It is located at line 300. Whatever x equals will be the screen color.
The next command is the help command. The help command displays on the screen the commands CIDS is currently using. It can be easily modified to display other important information, but what’s important is your decision. You might want to display how many files are taken and how many are available. For example, after NEXT t:, add PRINT “files used “; f ;'”files free “;mf-f
The rest of the lines will be filled in-in future instalments of this article. As you can see, there a many of them. For example, the commands make, find, adto, delete and display will be our next exercise.
- Imagine a full screen editor that lets you insert and delete characters in BASIC! We will have one of those next issue.
- Imagine an abort command that will restore a file to its original state AFTER you’ve messed it up!
- Imagine adding columns of numbers, taking the totals and putting them ANYWHERE in the database!
- Imagine sorting the database on any record!
- Imagine windowing in BASIC!
- Imagine merging new commands to perform specific tasks!
We will cover these tasks and more in upcoming issues as we fully explore the possibilities and usefulness of ‘CIDS Building A Database Program.’
For those of you who would like to get a jump on this series, a tape of the CIDS program is available directly from Mike for $14.95 ppd.-ed.
LIST OF VARIABLES USED SO FAR IN ORDER OF APPEARENCE.
VARIABLE USE
o INK color
mf maximum number of
files allowed.
ml max. no. of lines
allowed per file.
mc max. no. of characters
allowed per line.
fl flag.
f$(mf,ml,mc) 3-d array for our data
r$(ml,mc) 2-d array to store
deleted file.
g number of file in use
f number of files made
d$(28,8) holds commands & the
lines where they begin
h & i all purpose.
s$ temporary storage area.
prev number of previous file.
a$ command string.
l LENgth of a$
w$ word sliced out of a$.
w loop.
x PAPER color or x pos.
t loop.
Listing 1
10 GO SUB 9010: GO SUB 1506: GO TO 105
105 GO SUB 200: GO SUB 400: BEEP .025,40: GO TO 105
200 IF a$<>"" THEN GO TO 240
210 INPUT "READY>> "; LINE a$: PRINT ">===> ";a$
240 FOR l=1 TO LEN a$
261 IF fl=1 THEN RETURN
270 IF w$="thanks" THEN PRINT "Your welcome."
280 IF w$=" " THEN GO TO 200
285 IF LEN w$<4 THEN LET w$=w$+" "
290 RETURN
300 FOR w=1 TO 21: PRINT PAPER x;" ": NEXT w: RETURN
410 FOR x=1 TO 28: IF d$(x, TO 4)=w$( TO 4) THEN GO TO 450
420 NEXT x
430 RETURN
450 LET w$=w$( TO 4)
455 GO SUB VAL d$(x,5 TO ): IF a$<>"" THEN GO TO 465
460 RETURN
465 IF a$(1)<>"," THEN GO TO 460
470 LET a$=a$(3 TO ): GO TO 455
1506 CLS: LET x=3: INK 7: GO SUB 300: PRINT AT 0,7;"COMMANDS AVAILABLE": FOR t=1 TO 28: PRINT d$(t, TO 4); PAPER x;" ";: BEEP .01,50: NEXT t: INK 7: RETURN
9010 LET o=7: POKE 23609,6: LET mf=26: LET ml=21: LET mc=32: LET fl=0: DIM f$(mf,ml,mc): DIM r$(ml,mc): LET g=0: LET f=0: DIM d$(28,8): LET h=1: LET i=21: LET s$="": LET prev=0
9020 LET d$(14)="prev6500": LET d$(4)="clea1500": LET d$(17)="help1506": LET d$(3)="make1510": LET d$(1)="find500": LET d$(5)="next650": LET d$(6)="disp680": LET d$(7)="adto5000": LET d$(8)="keys8750": LET d$(9)="sort8600": LET d$(10)="dele1080": LET d$(16)="name1200"
9025 LET d$(21)="scra1080": LET d$(22)="loca500": LET d$(23)="crea1510": LET d$(24)="remo1080": LET d$(25)="left8300": LET d$(26)="righ8350": LET d$(27)="cent8400": LET d$(28)="modi8500"
9030 LET d$(13)="adju7000": LET d$(2)="eval150": LET d$(15)="copy1650": LET d$(19)="rest1760": LET d$(18)="save1540": LET d$(20)="load1250": LET d$(11)="zone8000": LET d$(12)="move1900": LET a$=""
9040 POKE 23692,255: PAPER 0: CLS : RETURN
9995 PRINT "[illegible] ";w$( TO 4);">";
9996 PRINT ("no file" AND w$="right")+("no file" AND w$="left")+("no file" AND w$="cent")+("no fie" AND w$="copy")+("no file" AND w$="move")+("no file" AND w$="zone2")+("no file" AND w$="edit1")+("no file" AND w$="bloc1")+("no file" AND w$="adto")+("out of range" AND w$="zone1")+("no file" AND w$="dele")+("no file" AND w$="display");
9997 PRINT ("see pg.28" AND w$="zone4")+("no file" AND w$="grap")+("no previous file" AND w$="prev")+("column?" AND w$="zone")+("next before find" AND w$="next")+("out of range" AND w$="disp")+("operator required" AND w$="eval")+("name short" AND w$="find")+("name short" AND w$="make");
9998 PRINT " pg.";(18 AND w$="disp")+(25 AND w$="left")+(27 AND w$="righ")+(27 AND w$="cent")+(12 AND w$="make")+(13 AND w$="find")+(14 AND w$="adto")+(16 AND w$="dele")+(18 AND w$="display")+(19 AND w$="next")+(20 AND w$="prev")+(22 AND w$="move")+(30 AND w$="zone")+(32 AND w$="eval")+(29 AND w$="sort")
9999 PRINT : RETURN
LINE ANNOTATION
10 GO INITIALIZE DICTIONARY AND VARIBLES: DISPLAY COMMANDS
GO TO INPUT LOOP.
105 GO GET INPUT: SEARCH DICTIONARY
DO IT AGAIN.
200 IF a$ IS NOT EMPTY THEN SLICE OUT NEXT WORD.
210 IF a$ IS EMPTY THEN ACCEPT INPUT.
240 LOOP TO SLICE OUT WORD.
261 FLAG
270 SOMETHING CUTE
280 ERROR TRAP
285 IF w$(ord) IS TOO SHORT THEN PAD IT OUT.
290 DONE
300 SCREEN COLOR ADJUST
410 LOOP TO SEARCH d$(ictonary)
IF A MATCH IS FOUND THEN CONTROL GOES TO 450.
420 KEEP LOOPING
430 IF NO MATCH THEN RETURN.
450 CHOP OFF EXTRA CHARACTERS
455 GO TO THE SUBROUTINE SPECIFIED BY THE
LAST FOUR CHARACTER OF d$(): CHECK a$ AND
IF NOT EMPTY THEN CONTROL GOES TO LINE 465.
460 DONE
465 IF THE FIRST CHARACTER OF a$ IS A COMMA THEN
GO BACK TO THE SUBROUTINE YOU JUST CAME FROM.
470 SLICE OUT (,) AND SPACE THAT FOLLOWS. GOTO
SAME SUBROUTINE.
1506 LOOP TO DISPLAY COMMANDS CURRENTLY AVAILABLE.
9010 INITIALIZE VARIABLES.
9020 INITIALIZE DICTIONARY
9025 DITTO
9030 DITTO
9040 DONE
9995 ERROR. PRINT CURRENT w$(ORD)
9996 PRINT ERROR
9997 DITTO
9998 DITTO
9999 DONE
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.