Cable Column

See all articles from Update April 1994
Author(s): Bill Cable
Publication: Update Magazine
Pub Details: Update April 1994
Date: April 1994
Pages: 30-31

ARCHIVE SERIES PART 16 : A REVIEW – DESCRIBING HOW TO USE SOME RECENTLY INTRODUCED PROCEDURES

The procedures listed last time when merged with our previous procedures made a program, QUERY. It can be used to interrogate any ARCHIVE database with its simple standardized menu interface. QUERY makes extensive use of the recently introduced procedures. Perhaps now is the time to describe how some of these procedures work. If you haven’t had time to type them in yet or have been stumped by all that I have introduced so far now you have time to catch up. Or to avoid the typing send me a formatted disk and return postage and I will send you a copy of query_prg or order the CABLE ARCHIVE ISSUE DISK from UPDATE and you will get lots of ARCHIVE goodies including query_prg.

In the PC World the user interface is all the rage now with the introduction of Windows and OS2. Besides multitasking (which they still can’t do as good as QDOS) their main claim to fame is the Graphical User Interface (GUI). The most important aspect being a standardized user interface. In my opinion the mouse is a totally overblown device. In novice situations it is good and for certain positioning tasks it is superior but as a general device to choose options for experienced users of a program it is cumbersome. The best method for choosing options, I think, is to take advantage of the mind’s ability to easily remember an option-character connection. If I want to print something then pressing a P is much quicker and faster than trying to move a little arrow to an arbitrary place on the screen with a mouse. Programming in ARCHIVE can’t be too graphical but these procedures standardize the user interface and work well with the option-character method for selection options..

I would like to encourage you to try and make the Miracle in Newport II on Saturday, May 14. I will be there and it would be nice to talk with readers of this column. I will be demonstrating my QLerk program and will be looking forward to visiting with fellow QLers and ARCHIVErs. The QL has been given a new lease on life with the Miracle GOLD CARD, QXL CARD, and now the SUPER GOLD CARD. It has been especially nice for us ARCHIVE programmers because although ARCHIVE is a nice language for developing database applications it runs somewhat slow on your basic MHZ QL. But when you increase the speed of the QL by a factor of 12 like the QXL CARD does ARCHIVE programs blaze across the screen. Hope to see you at Newport.

PREPARATION

Start ARCHIVE in your customary way so you see the ARCHIVE command prompt (>). What you need to type will be in Italics and don’t forget the <ENTER>. First we load the procedures saved as query_prg.

load "{}query"<ENTER>      where {} = device where
                           query_prg is (flp1_,mdv1_,etc)

Now set the screen and initialize needed variables

mode 0 : setup<ENTER>      always initialize setup first

You now have the procedures introduced in the last year loaded. Below I will describe them and give examples that illustrate how they work. The examples will be given to the ARCHIVE command prompt (>) but will activate procedures we have loaded with query_prg.

When giving the procedure name there is often a semicolon (;) followed by a list of variables separated by commas(,). This is how procedures are activated (called). The names of the variables following the procedure are descriptive of what they do. What you actually include when you call a procedure may be real numbers and literal text in quotes or variable names depending on the situation.

SIMPLE PROMPTS

Much of what I have tried to do so far is to introduce procedures to standardize simple program interaction with the user. The procedures in this category are :

acky;ln,mess$ : Acknowledge procedure is used to get the user to read a message (mess$) printed on the screen at line ln and press enter to continue. It does not return anything. Example :

cls:acky;10,"We are done now"<ENTER>

defy;ln,ques$,def$ : Default procedure asks the user a question (ques$) at line ln and suggests a default answer (def$). The user presses <ENTER> to accept the suggested answer (def$) or <ENTER> to give a null answer or enters their own answer. The answer is returned in lower case in global variable ans$. Example :

cls:defy;12,"Your name","bill"<ENTER>
answer defy prompt then print result
print ans$<ENTER>

inpy;ln,ques$ : Input procedure asks the user a question (ques$) at line ln and waits for the answer to be entered. The answer is return in lower case in global variable ans$. Example :

cls:inpy;12,"Your name"<ENTER>
answer inpy prompt then print result
print ans$<ENTER>

msg;ln,mess$ : Message procedure prints a message (mess$) in brackets at line ln. It returns nothing. Example :

cls:msg;20,"testing msg"<ENTER>

yorn;ln,ques$ : Yes or No procedure asks the user a question (ques$) that can only be answered by a yes or no answer. The answer is returned in global variable ans$ which will either be “y” or “n”. Example :

cls:yorn;12,"Are you ready"<ENTER>
answer yorn prompt then print result
print ans$<ENTER>

SINGLE LINE PROMPT WITH MULTIPLE OPTIONS

Often it can be handy to display multiple options on a single line and allow the user to choose one option by pressing a single key corresponding to the actual option desired.

key_choice;ln,mess1$,mess2$,options$,keys$ : Key choice procedure allows several options to be displayed on a single line (option line) and the user can make the choice by pressing a single key. If global variable ke=1 then an <ENTER> must also be pressed but if ke=0 then it does not. When ke=1 is set then set ke$=” KEY+ENTER ” (done already in setup) and if ke=0 then set ke$=” PRESS KEY “. This is a way to have a single procedure work in a quick mode (ke=0) where no <ENTER> is needed or a slower more friendly mode (ke=1) where <ENTER> needs to be pressed before action happens. The message on the line ln appears as :

    mess1$ + ke$ + mess2$ +"=>" + options$ + " : "

The list of acceptable keys are passed in the text variable called keys$ above and need to be in lower case..

Suppose we wanted the user to answer a question about a choice of colors we could use a call to key_choice :

cls:key_choice;14,"","Color","Black  Red  Green  White",
"brgw"<ENTER>
answer key_choice prompt and print ans$
print ans$<ENTER>

Now you can test to see whether ans$ is equal to “b” or “r” or “g” or “w” to see what was chosen.

PROMPT WITH OPTIONS SET IN ROWS&COLUMNS

Sometimes we have a situation that has many options and in order to sensibly display them I have a special procedure that uses an arrow that points to options set up in rows and columns and can be positioned to select an option. It also works nicely if the options can be laid out in just a single line like with key_choice above.

by_arrow;sr,nr,sc,nc,cwd,optlist$,strtpos : By arrow procedure where selections are made by positioning an arrow on the options displayed in a row/column format (option matrix) and pressing <ENTER>. The arrow can be moved with the arrow keys or by pressing characters corresponding to the option which will move the arrow to the option. The options need to be displayed to the screen in exact row and column format before the procedure is called. The arguments passed include :

1. sr : the starting row on the screen (0 to 23)

2. nr : the number of rows

3. sc : the starting column (0 to 80)

4. nc : the number of columns

5. cwd : the column width

6. optlist$ : a list of characters fixing which option the arrow should go to when a character is pressed. There should be nr*nc characters in optlist$ and columns are first so for a 3 row and 4 column option matrix the 6th character of the 12 characters in optlist$ would be row 2 and column 2. All characters in optlist$ must be upper case but numbers and other keyboard symbols are okay.

7. strtpos : starting position to have the arrow in when prompt starts up. A number from 1 to nr*nc.

When I display the option matrix I capitalize one character in each option which is the character to press to move the arrow to that option. Sometimes 2 options might be strongly tied to the same character like Flp1_ and Flp2. That is okay. You can put ‘f’ in the Flp1_ position and ‘f’ in the flp2_ position of optlist$. Pressing ‘f’ once will reach Flp1_ and pressing it again will reach Flp2_and pressing it again returns back to Flp1_. Pressing a character not in optlist$ will cause a ‘?’ to appear in place of the arrow and it won’t move. When <ENTER> is pressed whatever option is currently selected will be returned as a number in global variable ans. It will be between 1 and nr*nc. If the number zero (0) is pressed at any time before <ENTER> then by_arrow will return with ans=0 no matter which option the arrow was on. When displaying the options the block on the screen where the option matrix is displayed should be done in reverse screen (by using the special rv$ character initialized in the setup procedure). All this makes for a well behaved procedure that handles those many option situations.

Setting up a by_arrow call first requires printing an option matrix on the screen in reverse characters. Suppose we wanted to have the user choose among several colors. Everything has to be typed in one long line since we are working from the ARCHIVE prompt. In a program you could use several lines. Press <F5> if you have an error so you can edit the line :

cls:print at 10,1;"Choose a color  : ";at 11,1;rv$;"  Red
Green    Blue ";at 12,1;" Indigo   Violet    Black ";rv$;:
by_arrow;11,2,2,3,8,""RGBIVB",1<ENTER>
If error <F5> else answer by_arrow prompt then print ans
print ans<ENTER>

Inside your program you would check the value of ans which would range from 1 to 6 or 0 if the user pressed 0. Red=1, Green=2, Blue=3, Indigo=4, Violet=5, Black=6. It takes a little fussing to get the spacing right in the option matrix. Notice my by_arrow call specifies an 8 character width for each option starting at column 2 and row 11.

Notice how procedures like device and directory we used in the QUERY program. Next time more explanations and new procedrues. Until then or Newport, Happy Archiving!