home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / commandr.zip / COMMANDR.COM / COM-INC.CLA next >
Text File  |  1988-08-20  |  6KB  |  167 lines

  1.         MODULE('COMMANDR')
  2.           PROC(INPUT)
  3.           PROC(CHK_KEYS)
  4.           PROC(ALERT_KEYS)
  5.           PROC(CHK_IDX_KEYS)
  6.          .
  7.  
  8. !GLOBAL VARIABLES
  9.  
  10. FST_FLD        SHORT   ! THESE 3 FIELDS TRACK SCREEN ENTRY LOCATION
  11. LST_FLD        SHORT
  12. CUR_FLD        SHORT
  13.  
  14. HLP_FIND    LONG    ! THIS FIELD SETS WHERE TO READ HELP FILE
  15.  
  16. COUNT        LONG    ! THESE FIELDS KEEP TRACK OF WHERE YOU ARE IN A
  17. MAX_COUNT   LONG    ! POINTER FIELD
  18.  
  19. HLP_FILE    FILE    ! HELP FILE DECLARATION
  20. MEM_KEY        KEY(REC_KEY)
  21. HLP_NTS        MEMO(312)
  22.  
  23. HLP_REC        RECORD
  24. REC_KEY        LONG
  25.    .     .
  26.  
  27.      OMIT('**END**')
  28.  
  29. When I first started using Clarion 1 I was a little disappointed at the
  30. way it handled entry.  I felt like the process got "lost" in a loop when
  31. the user was filling in screen data.
  32.         Loop 
  33.       Accept
  34.           if fields() = Field() then break.
  35.         .
  36.  
  37. The above is a simple way to fill in a screen if you do not want to do any
  38. kind of processing to a field until the last field is enter. Worse than that,
  39. once a control key is pressed, the loop is left until the program returns to
  40. where it was before the control key was pressed. If you wanted any "live"
  41. prompts that were keyed to fields you were out of luck.  The first time an
  42. ESC was pressed....your helps went dead.
  43.  
  44. In the past, before Clarion, we always had 3 or 4 lines at the bottom of the
  45. screen to remind the operator of the commands and to describe the field. We
  46. tried using the Clarion Help System, but we did not like the help disappearing
  47. before the field was entered. What I ended up doing was writing COMMANDR, a
  48. group of procedures that gives the programmer greater control over screen
  49. input.  Commandr does 2 things
  50.     1) It puts a prompt in a text field call hlp_nts.
  51.     2) it then can optionally do an accept statement
  52.  
  53. Commandr gets its prompt from a file named HLP_FILE which is defined above.
  54. The Procedures In COMMANDR and their uses are:
  55.  
  56. INPUT(REC_WIN,PROMPT)
  57. REC_WIN is the initial value to be used to find the hlp record
  58.         REC_KEY {the key to HLP_FILE} is derrived by adding REC_WIN + HLP_FIND
  59.     HLP_FIND is set at the beginning of a procedure to mark an area of
  60.     HLP_NTS for a screen
  61.  
  62. An Example
  63.  
  64.    {SCREEN DEFINITION}
  65.      3 FIELDS TO ENTER: FIRST NAME, LAST NAME AND ADDRESS
  66.      DEFINE THE LAST FIELD (field #4) as a TEXT field 4x76
  67. ============================================================     
  68.      CODE
  69.      FST_FLD = 1 OR ?FST_NAME
  70.     LST_FLD = FIELDS() - 1  {The last field is the message area remember}
  71.     CUR_FLD = FST_FLD  {This is Where we want to start our entry}
  72.     ALERT_KEYS         {Will explain later}
  73.     HLP_FIND = 100     {The HLP records for this screen are 101 - 103}
  74.     LOOP
  75.       .
  76.       .     any processing to be done before entry of CUR_FLD
  77.           .
  78.       SELECT(CUR_FLD)
  79.       INPUT(CUR_FLD,'-') {call the input routine}
  80.       .
  81.       .  any processing to be done after entry of CUR_FLD
  82.       .
  83.       CHK_KEYS  {Process any ALERT KEYS or increment CUR_FLD
  84.       IF CUR_FLD > LST_FLD THEN BREAK. {Finished with input?}
  85.        END OF LOOP
  86.  
  87. Ok...What happens?
  88.  
  89. Input reads the HLP_FILE and displays the memo in HLP_NTS
  90. It then does an ACCEPT at the field # of CUR_FLD and returns
  91. Any processing that you want to is then done this might be
  92.   IF KEYCODE() = CTRL_ENTER THEN DO SAVE_REC. or
  93.   IF KEYCODE() = CTRL_ESC THEN RETURN.
  94. CHK_KEYS then processes any other ALERTed keys and changes CUR_FLD as needed
  95.    If there were no ALERTed keys then CHK_KEYS increments CUR_FLD by 1.
  96.  
  97. When CUR_FLD > LST_FLD the LOOP is terminated.  At no time is the operator
  98. allowed to wander through the screen structure without the program knowing it.
  99.  
  100.  
  101. OTHER PROCEDURES IN COMMANDR.CLA
  102. CHK_KEYS      Processes the keys that would normally be handled by
  103.           Clarion internally.  For example the ESC reduces CUR_FLD
  104.           by one, which has the effect of Selecting the Previous field.
  105.           It will also ignore keys that you might be using simply by 
  106.           adding the statements:
  107.                OF <KEY_NAME>
  108.               RETURN
  109.                                    
  110. CHK_IDX_KEYS  does the same as CHK_KEYS on INDEXED {REPEAT} Fields.
  111.            This procedure needs to be improved on. It was written in
  112.           a hurry. I needed someway to enter a series of tables and
  113.           edit them using COMMANDR. What is needed is a way to back
  114.           up through a series of tables without going back to the first
  115.           field in the REPEAT STRUCTURE.
  116.  
  117.  
  118. INPUT(REC_WIN,PROMPT) As stated above REC_WIN is used to determine what
  119.               Help Record to display in the HLP_NTS field.
  120.               Prompt is used to determine whether or not to do
  121.               an ACCEPT
  122.               Valid Prompts are:
  123.                   '-' : Display Message and do an ACCEPT
  124.                           'N' : Display Message and Return
  125.                           'C' : Clear any Message and Return
  126.  
  127. ALERT_KEYS ALERT the keys used by COMMANDR..you can add to this list any
  128.            keys that you ALERT for your processing
  129.  
  130.  
  131. OTHER UTILITIES
  132.  
  133. I have included some simple programs that edit the HLP_FILE. These are very,
  134. very primitive.  If anyone gets motivated to enhance these let me know, I
  135. want a copy.  The main purpose of these programs is to give the developer a
  136. way to modify the help file.
  137.  
  138. MAK_HELP (COMPILES TO EDIT_HLP) The name change has to do with my state of
  139.          mind when I wrote this. . .
  140.          Give it a number and it will show you an existing record or allow
  141.          you to create a new one
  142.  
  143.  
  144. COPY_HLP: Give this a range of keys to copy from and range to copy to.
  145.       This is a quick and dirty way to duplicate a records.
  146.           WARNING: No checking is done to see the ranges are valid and
  147.           if the a record exists, then it is over-written. I just assumed
  148.           that I would know what I was doing...
  149.  
  150.  
  151. Well, thats all there is to COMMANDR...hope you find it useful.
  152.  
  153. If you do like it and want to encourage me to send other "gems" then send
  154. me $10 or more and I will most encouraged. . .
  155. COMMANDR is Copyrighted by:
  156.         Mike Rhea
  157.                 4714 Clay
  158.                 Houston, TX 77023
  159.                 (713) 926-1711
  160.  
  161. but you may use it freely...However, please leave the copyright notice in
  162. the source files...
  163.  
  164. Thanks...
  165. Mike
  166.  
  167. **END**