home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
clarion
/
commandr.zip
/
COMMANDR.COM
/
COM-INC.CLA
next >
Wrap
Text File
|
1988-08-20
|
6KB
|
167 lines
MODULE('COMMANDR')
PROC(INPUT)
PROC(CHK_KEYS)
PROC(ALERT_KEYS)
PROC(CHK_IDX_KEYS)
.
!GLOBAL VARIABLES
FST_FLD SHORT ! THESE 3 FIELDS TRACK SCREEN ENTRY LOCATION
LST_FLD SHORT
CUR_FLD SHORT
HLP_FIND LONG ! THIS FIELD SETS WHERE TO READ HELP FILE
COUNT LONG ! THESE FIELDS KEEP TRACK OF WHERE YOU ARE IN A
MAX_COUNT LONG ! POINTER FIELD
HLP_FILE FILE ! HELP FILE DECLARATION
MEM_KEY KEY(REC_KEY)
HLP_NTS MEMO(312)
HLP_REC RECORD
REC_KEY LONG
. .
OMIT('**END**')
When I first started using Clarion 1 I was a little disappointed at the
way it handled entry. I felt like the process got "lost" in a loop when
the user was filling in screen data.
Loop
Accept
if fields() = Field() then break.
.
The above is a simple way to fill in a screen if you do not want to do any
kind of processing to a field until the last field is enter. Worse than that,
once a control key is pressed, the loop is left until the program returns to
where it was before the control key was pressed. If you wanted any "live"
prompts that were keyed to fields you were out of luck. The first time an
ESC was pressed....your helps went dead.
In the past, before Clarion, we always had 3 or 4 lines at the bottom of the
screen to remind the operator of the commands and to describe the field. We
tried using the Clarion Help System, but we did not like the help disappearing
before the field was entered. What I ended up doing was writing COMMANDR, a
group of procedures that gives the programmer greater control over screen
input. Commandr does 2 things
1) It puts a prompt in a text field call hlp_nts.
2) it then can optionally do an accept statement
Commandr gets its prompt from a file named HLP_FILE which is defined above.
The Procedures In COMMANDR and their uses are:
INPUT(REC_WIN,PROMPT)
REC_WIN is the initial value to be used to find the hlp record
REC_KEY {the key to HLP_FILE} is derrived by adding REC_WIN + HLP_FIND
HLP_FIND is set at the beginning of a procedure to mark an area of
HLP_NTS for a screen
An Example
{SCREEN DEFINITION}
3 FIELDS TO ENTER: FIRST NAME, LAST NAME AND ADDRESS
DEFINE THE LAST FIELD (field #4) as a TEXT field 4x76
============================================================
CODE
FST_FLD = 1 OR ?FST_NAME
LST_FLD = FIELDS() - 1 {The last field is the message area remember}
CUR_FLD = FST_FLD {This is Where we want to start our entry}
ALERT_KEYS {Will explain later}
HLP_FIND = 100 {The HLP records for this screen are 101 - 103}
LOOP
.
. any processing to be done before entry of CUR_FLD
.
SELECT(CUR_FLD)
INPUT(CUR_FLD,'-') {call the input routine}
.
. any processing to be done after entry of CUR_FLD
.
CHK_KEYS {Process any ALERT KEYS or increment CUR_FLD
IF CUR_FLD > LST_FLD THEN BREAK. {Finished with input?}
END OF LOOP
Ok...What happens?
Input reads the HLP_FILE and displays the memo in HLP_NTS
It then does an ACCEPT at the field # of CUR_FLD and returns
Any processing that you want to is then done this might be
IF KEYCODE() = CTRL_ENTER THEN DO SAVE_REC. or
IF KEYCODE() = CTRL_ESC THEN RETURN.
CHK_KEYS then processes any other ALERTed keys and changes CUR_FLD as needed
If there were no ALERTed keys then CHK_KEYS increments CUR_FLD by 1.
When CUR_FLD > LST_FLD the LOOP is terminated. At no time is the operator
allowed to wander through the screen structure without the program knowing it.
OTHER PROCEDURES IN COMMANDR.CLA
CHK_KEYS Processes the keys that would normally be handled by
Clarion internally. For example the ESC reduces CUR_FLD
by one, which has the effect of Selecting the Previous field.
It will also ignore keys that you might be using simply by
adding the statements:
OF <KEY_NAME>
RETURN
CHK_IDX_KEYS does the same as CHK_KEYS on INDEXED {REPEAT} Fields.
This procedure needs to be improved on. It was written in
a hurry. I needed someway to enter a series of tables and
edit them using COMMANDR. What is needed is a way to back
up through a series of tables without going back to the first
field in the REPEAT STRUCTURE.
INPUT(REC_WIN,PROMPT) As stated above REC_WIN is used to determine what
Help Record to display in the HLP_NTS field.
Prompt is used to determine whether or not to do
an ACCEPT
Valid Prompts are:
'-' : Display Message and do an ACCEPT
'N' : Display Message and Return
'C' : Clear any Message and Return
ALERT_KEYS ALERT the keys used by COMMANDR..you can add to this list any
keys that you ALERT for your processing
OTHER UTILITIES
I have included some simple programs that edit the HLP_FILE. These are very,
very primitive. If anyone gets motivated to enhance these let me know, I
want a copy. The main purpose of these programs is to give the developer a
way to modify the help file.
MAK_HELP (COMPILES TO EDIT_HLP) The name change has to do with my state of
mind when I wrote this. . .
Give it a number and it will show you an existing record or allow
you to create a new one
COPY_HLP: Give this a range of keys to copy from and range to copy to.
This is a quick and dirty way to duplicate a records.
WARNING: No checking is done to see the ranges are valid and
if the a record exists, then it is over-written. I just assumed
that I would know what I was doing...
Well, thats all there is to COMMANDR...hope you find it useful.
If you do like it and want to encourage me to send other "gems" then send
me $10 or more and I will most encouraged. . .
COMMANDR is Copyrighted by:
Mike Rhea
4714 Clay
Houston, TX 77023
(713) 926-1711
but you may use it freely...However, please leave the copyright notice in
the source files...
Thanks...
Mike
**END**