home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / demos / 139 / menu.ap < prev    next >
Encoding:
Text File  |  1988-02-12  |  2.7 KB  |  89 lines

  1. clear
  2. trace off
  3.  
  4. |-------------------------------------------------------------|
  5. | Sample AutoPilot for doing simple text menus in ST-Talk Pro |
  6. |   by John DeMar 2/7/88                                      |
  7. |-------------------------------------------------------------|
  8. | Text menus use the Menu function for branching to one of    |
  9. |   several places in an Autopilot program.                   |
  10. | 1) Build arrays to hold the characters associated with each |
  11. |   menu selection, the menu text for each selection and the  |
  12. |   labels to go to upon selecting the character.             |
  13. | 2) Enter the labels and commands for each menu selection.   |
  14. | 3) Fill the arrays with their associated data.              |
  15. | 4) Do the Menu funtion.                                     |
  16. |-------------------------------------------------------------|
  17.  
  18. keys='a'        | force keys to be a character data type.
  19. msgs="a"        | force msgs to be a string data type.
  20. _labels         | force labels to be a label type.
  21. array keys 5    | make the array for the menu keys.
  22. array msgs 5    | make the array for the menu messages.
  23. array labels 5  | make the array for the menu labels.
  24.  
  25. @defer    | Enclose labels for menus in a "do nothing" function.
  26.           |  This keeps autopilot from doing this lines the first time through.
  27. _labela
  28. print "~Doing label a.~"
  29. GOTO menu1
  30.  
  31. _labelb
  32. print "~Doing label b.~"
  33. GOTO menu1
  34.  
  35. _labelc
  36. print "~Doing label c.~"
  37. GOTO menu1
  38.  
  39. _labeld
  40. print "~Doing label d.~"
  41. GOTO menu1
  42.  
  43. _labele
  44. print "~Doing label e.~"
  45. GOTO more
  46.  
  47. @endsub | End of the "do nothing" function.
  48.  
  49. | Fill the keys array with menu selections' keys.
  50. keys[1]='a'     
  51. keys[2]='b'
  52. keys[3]='c'
  53. keys[4]='d'
  54. keys[5]='e'
  55.  
  56. | Fill the messages array with the menu text for each key.
  57. |  Add some special text at the begining and end for esthestics.
  58. msgs[1]="~a) Do things at label a    "
  59. msgs[2]= "b) Do things at label b"
  60. msgs[3]="~c) Do things at label c    "
  61. msgs[4]= "d) Do things at label d"
  62. msgs[5]="~e) Do things at label e and exit~~ Select a,b,c,d or e >"
  63.  
  64. | Fill the label array with the location to goto for each key value.
  65. labels[1]=labela
  66. labels[2]=labelb
  67. labels[3]=labelc
  68. labels[4]=labeld
  69. labels[5]=labele
  70.  
  71. | A place to come back to when re-running the menu.
  72. _menu1
  73.  
  74. | Run the menu and branch to the selected label!
  75. menu 0 keys labels msgs
  76. | Menu function should never get here unless there was a data type error!
  77. |  or <undo> was pressed.
  78. Print "~Undo!~"
  79. QUIT
  80.  
  81. |-----------------------------------------------------------
  82. _more   | a place to go to when continuing with the program.
  83.  
  84. Print "~Done!~" | Just say Done and
  85. QUIT            | quit for now.
  86.  
  87.  
  88.  
  89.