home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / PULDOWN.ZIP / TUTORIAL.BAS < prev    next >
Encoding:
BASIC Source File  |  1990-10-23  |  25.9 KB  |  624 lines

  1. '                           ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  2. '                           ██ TUTORIAL.BAS ██
  3. '                           ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  4.  
  5. 'The assumption is made that this file is being read in the QuickBASIC
  6. 'environment--that's what it was designed for.
  7.  
  8. 'This file is a working program, with exactly the same code as PULDOWN.BAS,
  9. 'and, if PULDOWN.QLB is loaded, you can run it anytime. Infact, if you don't
  10. 'have PULDOWN.QLB loaded, please do so now: exit QB and reload with the
  11. 'command line:
  12.  
  13. '       QB /L PULDOWN
  14. '
  15. 'This file differs from PULDOWN.BAS only in that it has extensive comments
  16. 'that show you how how the program works and how to customize.
  17. 'Just be sure that you save at least one original of this file on a diskette,
  18. 'and it is highly recommended that you read all the way through the comments
  19. 'at least once before editing.
  20. '
  21.  
  22. 'If you have trouble following some of the explanations, don't fret--customizing
  23. 'PULDOWN is actually fairly easy. There's a section at the end of this file
  24. 'that guides you through a customizining session. Search for: STEP BY STEP.
  25.  
  26. 'Terms used:
  27.  
  28. '       "Barmenu" is used to indicate the horizontal menu at the top of
  29. '       of the screen.
  30. '
  31. '       "Pulldown" refers to a pulldown window menu such as appears when
  32. '       you press ALT+F in QB.
  33. '
  34. '       "Trigger letter" indicates a character in a pulldown that can be
  35. '       pressed to instantly activate a menu item without actually moving
  36. '       to it. They appear in the pulldowns in the opposite color of the
  37. '       other characters in the menu item. To see an example of a trigger
  38. '       letter (my terminology), press Alt then ENTER: the O in "Open
  39. '       Program " is a trigger letter, as are many others in the QB menu.
  40. '
  41. '       QB means QuickBASIC in general and the QB Environment in particular.
  42. '       AL means Assembly Language.
  43. '
  44. '       VM and vm are frequently used in variable names. They stand for
  45. '       Vertical Menu, i.e. pulldown. This might help you in reading the code.
  46. '
  47. '       If you're not clear on what a QuickLibrary (QLB) or Library (LIB)
  48. '       module is, don't despair. A QLB and a LIB that have the same filename
  49. '       are essentially the same thing. They are binary files that are CALLed
  50. '       by QB much like subroutines. The crucial difference between them is
  51. '       that a QLB must be loaded at the same time as QB to work, while a LIB
  52. '       must be present in the QB path only when you compile BASIC code to
  53. '       an EXE file.
  54. '
  55. '       Other technical terms used here are part of the QuickBASIC vocabulary,
  56. '       and you should consult your QB manuals and books for them. This text
  57. '       is written for programmers and a minimal familiarity with programming
  58. '       terms and concepts is assumed, but some accommodations are made for
  59. '       the raw beginner.
  60. '
  61. 'The presence of an inverse block " ██ " marks crucial information--don't
  62. 'miss them.
  63. '
  64. 'Some of the crucial information is in the last section: END NOTES. Although
  65. 'crucial, it is not needed while familiarizing yourself with the program.
  66.  
  67. 'Notice that there's no DEFINT and each number is declared an integer with
  68. ' n% since there's no way of knowing whether a program that incorporates
  69. ' PULDOWN won't need other kinds of number declarations.
  70.  
  71. '"PULL" is the actual name of the Assembly Language routine that is CALLed.
  72. 'That name cannot be changed, except by aliasing. The names of the variables
  73. 'that are used before the actual call can be changed (if you enjoy making
  74. 'trouble for yourself).
  75.  
  76. 'Program lines are tabbed (except for labels), like the one 5 lines below:
  77.  
  78. '▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  79. 'PROGRAM BEGINS:
  80.  
  81.         DECLARE FUNCTION PULL% (BYVAL Inverse%, BYVAL Normal%, BYVAL BarMenu%, BYVAL KeyOff%, BYVAL BarNumber%, BYVAL VM1%, BYVAL VM1A%, BYVAL VM10%, BYVAL VM2%, BYVAL VM2A%, BYVAL VM20%, BYVAL VM3%, BYVAL VM3A%, BYVAL VM30%, BYVAL VM4%, BYVAL VM4A% _
  82. , BYVAL VM40%, BYVAL VM5%, BYVAL VM5A%, BYVAL VM50%, BYVAL VM6%, BYVAL VM6A%, BYVAL VM60%, BYVAL VM7%, BYVAL VM7A%, BYVAL VM70%)
  83.  
  84.  
  85. '█ All the code after this point can be put into a Subprogram in your ultimate
  86. '  program, provided you put a 'CALL MySub'in the main program and restructure
  87. '  the ensuing code somewhat (like eliminating RETURNs), but that subject is
  88. '  beyond the scope of this file.
  89. '█ In any case, the above declaration must be in the main program and at or
  90. '  near the top.
  91.  
  92.        
  93. 'This is where the customizing part really starts.
  94. 'The next cluster of code initializes the barmenu items, of which there
  95. 'can be no more than seven ██ and there must be no fewer than one.
  96. '
  97. '█ All the barmenu items must be in the same string, as in BarMenu$ below.
  98. '█ Each item MUST be ten spaces long, including blanks.
  99. '█ The BarNumber% variable must have the total number of barmenu items, in
  100. '  this case 7.
  101.  
  102. '█ BarMenuKeys$ holds the first letter of each of the barmenu items.  They
  103. '  must be entered in the exact number, form and order in which they appear
  104. '  on the menu, with no blank spaces. █ If you change the number or order of
  105. '  barmenu items, don't forget to change this string and the BarNumber% variable.
  106. '██ You cannot have the same letter appear twice in BarMenuKeys$ (actually,
  107. '   you can, but the first instance will be selected every time)
  108.  
  109. '█ A barmenu item can consist of two or more words, so long as they fit in
  110. '  ten spaces.
  111.  
  112.  
  113.         BarMenu$ = " English   Italian   German    French    Spanish   Hellos    Quit     "
  114.         BarMenu% = SADD(BarMenu$)
  115.         BarMenuKeys$ = "EIGFSHQ"
  116.         KeyOff% = SADD(BarMenuKeys$)    'the  'Off' in KeyOff% stands for offset
  117.         BarNumber% = 7
  118.  
  119. 'BarMenu section ends
  120. '▀▀▀▀▀
  121.        
  122. '█ Normal% is the foreground color of characters. Inverse% is background
  123. 'color. First we must determine if we're in a mono system or color. The
  124. 'cluster of code below does that and assigns the colors. Note that only the
  125. 'last, CASE ELSE clause applies to color. Mixing the foreground and background
  126. 'colors in a one byte value is a tedious business--if you want to experiment,
  127. 'round up the usual reference suspects. However, a partial COLOR MIX table is
  128. 'provided at the end. The only firm rule is that Inverse% and Normal% must be
  129. 'symmetrical--you can't have red on green for one and green on yellow for the
  130. 'other.
  131.  
  132.         DEF SEG = 0
  133.         Attr% = PEEK(&H410)             'this is where BIOS stores video state
  134.         SELECT CASE Attr%
  135.                 CASE 48 TO 63
  136.                         Inverse% = 112 'or &H70       'Compare Attr% to all
  137.                         Normal% = 7                   'byte numbers that have
  138.                         Attr% = 0                     'bits 5 & 4 set. If they
  139.                 CASE 112 TO 127                       'are both set, it means
  140.                         Inverse% = 112                'mono, otherwise, color.
  141.                         Normal% = 7
  142.                         Attr% = 0
  143.                 CASE 176 TO 191
  144.                         Inverse% = 112
  145.                         Normal% = 7
  146.                         Attr% = 0
  147.                 CASE 240 TO 255
  148.                         Inverse% = 112
  149.                         Normal% = 7
  150.                         Attr% = 0
  151.                 CASE ELSE
  152.                         Inverse% = 31           'bright white on blue
  153.                         Normal% = 121           'bright blue on white
  154.         END SELECT
  155.         DEF SEG
  156.  
  157. 'The Inverse% and Normal% variables are not used in the BASIC part, they
  158. 'are strictly parameters to be passed to the AL routine. And yes, there are
  159. 'several other ways of going about this. Use your favorite method, so long
  160. 'as the two color values end up properly assigned.
  161.  
  162. '▄▄▄▄▄▄▄
  163. 'Pulldown initializiation sets begin:
  164.  
  165. 'This is where the fun begins. The contents and form of the pulldowns is
  166. 'determined in the next section of code.  Examine the first set, which
  167. 'initializes the first (leftmost) pulldown.  The format will be explained
  168. 'in the next comment.
  169.  
  170.         VM1% = 4
  171.         VM1A% = 11
  172.         VM1$ = " Hundreds    Tho_usands  Millions    Billions   "
  173.         VM10% = SADD(VM1$)
  174.        
  175. '█ The first value, VM1% determines the number of items in the pulldown,
  176. '  that is, the number of lines, or depth (excluding the box).  You can,
  177. '  theoretically have as many as 21 lines.
  178.  
  179. '█ The second value, VMnA%, determines the number of characters in the
  180. '  item field of the pulldown, including blanks, but excluding the box.
  181. '  As an example, the item field of the first item in the first pulldown is:
  182.  
  183. '                            " Hundreds   "
  184. '                             
  185. '  If you've counted the spaces, it comes out to 12, not eleven. ██ The
  186. '  field must always be 1 space greater than what is declared in VMn% █
  187. '  --more on that later.
  188. '  You can make the pulldowns as wide as you wish, so long as there's room
  189. '  on the screen.  The width of the box (2 spaces) must be taken into
  190. '  account and the fact that each pulldown begins in the same column as its
  191. '  corresponding barmenu item.  So, on the first pulldown, the item field
  192. '  can be as wide as 76 spaces, but only 20 on the seventh pulldown.██
  193.  
  194. '  VMn$ is the string that actually carries the items in a pulldown.  They
  195. '  must all be in the same string, and the field length must be consistent
  196. '  throughout the string.
  197.  
  198. '  Finally, VMn0% determines where BASIC stores the string so that PULDOWN.QLB
  199. '  and PULDOWN.LIB can find it.  Leave it alone.
  200.  
  201. '██ The cluster of pulldown initialization sets must be contiguous and in
  202. '   ascending order, as they are here, where the VM2 set follows the VM1 set
  203. '   etc. ██
  204.  
  205. 'To get a taste of what customizing is like, use the Insert key to change
  206. 'one of the words below in VM2$ (taking care not to change the length of the
  207. 'string) then Run (F5) to see the change.
  208.  
  209.         VM2% = 9
  210.         VM2A% = 7
  211.         VM2$ = "Uno     Due     Tre     _QuattroCinque  Sei     Sette   Ot_to   Nove    "
  212.         VM20% = SADD(VM2$)
  213.         
  214. 'The VM3 set illustrates the use of Ctrl+Char and Function keys, as displayed
  215. 'in the line:
  216.  
  217. '                                                                 
  218. 'VM3$ = " Ein...Ctrl+E  Z_wei         Dr_ei         Vier          Funf..or F10 "
  219.  
  220. 'These two keypresses greatly improve speed and convenience in accessing crucial
  221. 'and often-used program features since they can be used anytime the pulldowns
  222. 'are active, even if the user is not in the pulldown containing the menu items
  223. 'in question.
  224.  
  225. 'ABOUT CTRL+CHAR:
  226. '~~~~~~~~~~~~~~~
  227. 'Any letter character can be used but avoid using C--it encourages bad habits.
  228.  
  229. 'Char can duplicate a trigger letter with a different meaning, for
  230. 'example Ctrl+e can mean Exit, while trigger key "e" could mean "erase".
  231.  
  232. 'It is irrelevant whether Char is displayed or pressed in upper or lower
  233. 'case. PULDOWN will always return the upper case ASCII values.
  234.  
  235. 'Use restraint with Ctrl+Char--it should be limited to a few letters that the
  236. 'user can remember easily and are logical, like Ctrl+Q for 'Quit, or Ctrl+F
  237. 'for File.
  238.  
  239. 'ABOUT FUNCTION KEYS:
  240. '~~~~~~~~~~~~~~~~~~~
  241. 'F11 and F12 are not supported.
  242.  
  243. 'The Function keys are most useful for commands that are in effect throughout
  244. 'the program--not just during the menu, like "save what I've entered so far,"
  245. 'or "let's start over".
  246.  
  247.         VM3% = 5
  248.         VM3A% = 13
  249.         VM3$ = " Ein...Ctrl+E  Z_wei         Dr_ei         Vier          Funf..or F10 "
  250.         VM30% = SADD(VM3$)
  251.        
  252. 'You may have noticed that some of the items are broken up by underscores,
  253. 'as in " Vingt et deu_x " below. That's what makes a trigger letter.
  254. 'When a pulldown with a trigger letter is activated, pressing a trigger
  255. 'letter calls that menu function without need of arrow keys or ENTER.
  256.  
  257. ' ██ An underscore must precede the trigger letter.  Items that do not have
  258. ' a trigger letter must have an extra blank space to maintain the uniformity
  259. ' of field length. (That's why declared field length is one less than actual)
  260.  
  261. ' ██ There is a limit of 5 trigger letters per pulldown.
  262. ' ██ You cannot duplicate a trigger letter within the same pulldown, but
  263. '    you can have the same trigger letter in different pulldowns.
  264.  
  265.         VM4% = 3
  266.         VM4A% = 20                              '
  267.         VM4$ = "Vingt et un          Vingt et deu_x       Vingt et trois       "
  268.         VM40% = SADD(VM4$)
  269.        
  270.         VM5% = 4
  271.         VM5A% = 14
  272.         VM5$ = "Ciento         Ciento y _uno  Ciento y _dos  Cien_to y tres "
  273.         VM50% = SADD(VM5$)
  274.        
  275. ' █ You can have as few as 1 pulldown or a as many as 7,██ but make sure
  276. '   that the BarNumber% variable reflects the number.
  277.  
  278. ' █ A reminder: as you get to the higher pulldowns, be mindful of how many
  279. '   screen columns are left.
  280.  
  281.         VM6% = 3
  282.         VM6A% = 16
  283.         VM6$ = " Hello, there     Live long and    Prosper.        "
  284.         VM60% = SADD(VM6$)
  285.        
  286. 'Notice that each barmenu item must have a pulldown, even if only one line
  287. 'deep. ██ You cannot have a barmenu item without a pulldown:
  288.  
  289.         VM7% = 1                        'one item
  290.         VM7A% = 13
  291.         VM7$ = " _Quit...Esc  "
  292.         VM70% = SADD(VM7$)
  293.  
  294. 'The cluster of pulldown initialization sets end here.
  295. 'All the code that follows is optional, except for the actual CALL PULL
  296.  
  297.         CLS
  298.  
  299. '█ If you wish to add any features to the menu screen, like the name of the
  300. '  program--as is done here, or a frame around the screen, do so before █
  301. '  calling PULL:
  302.  
  303.         LOCATE 2, 34
  304.         SELECT CASE Attr%
  305.                 CASE 0
  306.                         COLOR 0, 7
  307.                 CASE ELSE
  308.                         COLOR 7, 1      'white on blue
  309.         END SELECT
  310.  
  311.                 PRINT " PULDOWN.BAS "
  312.                 COLOR 7, 0
  313.  
  314.  
  315. 'Here PULDOWN is actually called as a function named PULL. Its return value
  316. 'is put into RETVAL%, but you may change that.
  317. 'Notice that the list of parameters is exceedingly long. Be careful you don't
  318. 'chop it off during the editing process. Also there is no actual CALL in the
  319. 'call--the word is used in the text for clarity.
  320.  
  321.  
  322.         RETVAL% = PULL%(Inverse%, Normal%, BarMenu%, KeyOff%, BarNumber%, VM1%, VM1A%, VM10%, VM2%, VM2A%, VM20%, VM3%, VM3A%, VM30%, VM4%, VM4A%, VM40%, VM5%, VM5A%, VM50%, VM6%, VM6A%, VM60%, VM7%, VM7A%, VM70%)
  323.     
  324. 'Before returning control to the main program, PULL erases the active
  325. 'pulldown, returns the barmenu to its "rest" state, and restores the screem
  326. 'below the barmenu to its pre-CALL condition.
  327.  
  328. 'PULL returns four kinds of values:
  329.  
  330. '       The first type consists exclusively of the number 1.  This indicates
  331. '       that the user has pressed ESC, and exited the menu without taking
  332. '       action.
  333.  
  334. '       The second type indicates that Ctrl+Char has been pressed, and returns
  335. '       a value between 64 and 90, which are ASCII codes except that 64
  336. '       indicates that a non-letter key has been pressed.
  337. '       (Again: Char may be pressed with or without Shift, but is returned
  338. '       as if with)
  339. '       █ In the 65-90 range, only the ones that you designate in the menu
  340. '       are actually valid. Identifying valid characters is done in the BASIC
  341. '       part of the program, as shown below.
  342.  
  343. '       The third type returns values between 159 and 168, and represent
  344. '       Function Keys 1 through 10. Each of these numbers is actually the scan
  345. '       code of the key plus 100 (i.e.: F1 = 59 + 100 = 159)
  346.  
  347. '       Values that are greater than 168 (and usually they will be >10,000)
  348. '       are the fourth type:  the offset within the data segment
  349. '       of the menu item that was selected. This will by far the most common
  350. '       return value. It is the address in memory of the menu item, and is
  351. '       rendered useful by means of PEEKs, as shown below.
  352. '
  353. 'To see how the Return Value works, use the QB Debug menu to AddWatch: RETVAL%.
  354. 'Make the next line of code below a breakpoint, and run the program four times.
  355. 'The first time, press Esc in the menu; the second time, Ctrl+Char; the third
  356. 'time, an F-Key, and finally select a menu item either  with ENTER or with a
  357. 'trigger key. Each time, as QB hits the breakpoint, look at RETVAL%.
  358.  
  359. 'Once PULDOWN has returned a value, its job is essentially over. Making something
  360. 'useful out that single number is the programmer's job--your job, and
  361. 'how you do it depends on your program requirements, and your programming
  362. 'style. What follows is a sparse but wide-ranging example of how it can be
  363. 'handled.  These are only suggestions.
  364.  
  365.         LOCATE 5, 1
  366.        
  367. 'First, check for ESC, Ctrl, and F-Keys
  368.  
  369.         SELECT CASE RETVAL%
  370.                 CASE 1
  371.                         GOTO Last       'Yes, it's ESC
  372.                 CASE 2 TO 68
  373.                         GOTO BadKey     'don't want these
  374.                 CASE 69
  375.                         GOTO IsCtrl     'we want this one -- CHR$(69) = E
  376.                 CASE 70 TO 167
  377.                         GOTO BadKey     'don't want these
  378.                 CASE 168
  379.                         GOTO IsFKey     'F10
  380.         END SELECT
  381.  
  382. 'If it's not ESC or Ctrl+Char, then the user must have selected one of the menu
  383. 'items. We must find out which one by retrieving the selected string and
  384. 'comparing it with all the possibilities.
  385.  
  386. 'The essence of my way of doing that is in the first line of the FOR/NEXT
  387. 'loop: we PEEK at RETVAL% and convert it to an ASCII CHR$. Then we add 1 to
  388. 'RETVAL%, and repeat the whole process as many times as it takes to get
  389. 'enough letters to identify the menu item. I have selected four characters.
  390. 'Infact, three should be plenty, but many menu items start with a blank
  391. 'because it looks better. If you will consistently have a blank in the first
  392. 'position, you can start the loop with RETVAL% + 1, and loop three times. Just
  393. 'be careful that each three-letter combination is unique--you wouldn't want
  394. 'to confuse "File" with "Fill Screen," for example--a four-loop PEEK would
  395. 'be needed to distinguish between these two.
  396.  
  397. 'Rather than concatenating (Final$ = A$ + B$ + C$), I am using a supposedly
  398. 'faster method: setting up a blank string of the proper length (RETVAL$),
  399. 'then filling it in with MID$:
  400.  
  401.         RETVAL$ = "    "
  402.  
  403.         FOR RT% = 1 TO 4
  404.                 MID$(RETVAL$, RT%, 1) = CHR$(PEEK(RETVAL%))
  405.                 RETVAL% = RETVAL% + 1
  406.         NEXT
  407.  
  408. 'Here too you might want to set up a breakpoint and a Watch, Run, and see
  409. 'what RETVAL$ looks like after you select a menu item.
  410.  
  411. 'Now comes the laborious part. The return string must be compared with
  412. 'with each menu item. In this sample program, only a few of the total
  413. 'items are compared. A working program will have as many CASEs as there
  414. 'are pulldown items.
  415.  
  416. 'There are a few things to watch out for.  The comparison string must be
  417. 'of the same length as the retrieved string. It must be exactly as it appears
  418. 'in its declared form, not its display form, including initial blanks
  419. '(unless you retrieve at RETVAL% + n), but █ most important, it means including
  420. 'any underscores, as in "_Qu":
  421.  
  422.         SELECT CASE RETVAL$
  423.                 CASE " Hel"                     'notice leading blank...
  424.                         GOSUB greeting
  425.                 CASE "Uno "                     '...but none here
  426.                         GOSUB italian
  427.                 CASE " Z_w"                     'Include underscore!
  428.                         GOSUB deutsch
  429.                 CASE "Ving"
  430.                         GOSUB francais
  431.                 CASE " _Qu"                     '(Quit)
  432.                         GOTO Last
  433.                 CASE ELSE
  434.                         GOTO AnyKey
  435.         END SELECT
  436.         GOTO Last
  437.  
  438. '(Please note that many of the items in the sample menu start with the
  439. ' same syllable, but that would rarely be the case in a "real" menu)
  440.  
  441. 'And here is the payoff. In a working program of course, a menu selection
  442. 'will usually branch to something more than just printing a message, but
  443. 'this does illustrate how to get to the actual work:
  444.  
  445. 'This next section handles the first three types of Return Value:
  446.  
  447. AnyKey:
  448.         PRINT "You have selected "; RETVAL$
  449.         GOTO Last
  450. IsCtrl:
  451.         PRINT "You have pressed Ctrl+e and selected  'Ein'"
  452.         GOTO Last
  453.  
  454. '█ Note that PULDOWN cannnot tell what menu item was selected when Ctrl+Char
  455. '  is pressed. That determination is made on the basis that each instance is
  456. '  associated with a particular menu item in the BASIC code: if Ctrl+e has
  457. '  been pressed, then it MUST be 'Ein'.
  458.  
  459. '...and the same goes for the Function keys:
  460.  
  461. IsFKey:
  462.                 PRINT "You have pressed F10 and selected 'Funf'"
  463.                 GOTO Last
  464. BadKey:
  465.                 PRINT "You have pressed an unassigned key"
  466.  
  467. Last:
  468.                 END
  469.  
  470. 'And here are handled the selected "working" menu items:
  471.  
  472. greeting:
  473.                 COLOR 16, 7
  474.                 PRINT "Hello   Hello"
  475.                 WHILE INKEY$ = "": WEND
  476.                 COLOR 7, 0
  477.                 RETURN Last
  478. italian:
  479.                 COLOR 0, 7
  480.                 PRINT "MA CHE, SCHERZI?"
  481.                 WHILE INKEY$ = "": WEND
  482.                 COLOR 7, 0
  483.                 RETURN Last
  484. deutsch:
  485.                 COLOR 16, 7
  486.                 PRINT "Ein VolksMenu. Wunderbar!"
  487.                 COLOR 7, 0
  488.                 RETURN Last
  489. francais:
  490.                 COLOR 1, 0
  491.                 PRINT "Yo, alouette..."
  492.                 COLOR 7, 0
  493.                 RETURN Last
  494.  
  495.  
  496. 'PROGRAM ENDS
  497.  
  498. '▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  499. 'STEP BY STEP:
  500.  
  501. 'Now we will go through a step-by-step exercise in customizing one of the
  502. 'pulldowns.  We will change the VM6 set "Hellos" to "List" consisting of
  503. 'these items: First, Second, Third, Fourth, Fifth, Sixth.
  504. 'This is what the original set looks like:
  505.  
  506. '        VM6% = 3
  507. '        VM6A% = 16
  508. '        VM6$ = " Hello, there     Live long and    Prosper.        "
  509. '        VM60% = SADD(VM6$)
  510. '
  511. 'First, we will change VM6% (depth) to 6, because that's how many items we have.
  512. 'Then we change VM7% (width) to 8 because the longest item is six letters long,
  513. 'and we want (at least) one blank space at either end just for esthetics.
  514. 'Then we edit the VM6 string to the new items, making sure that each field
  515. 'has 9 spaces (item length + 1, remember?).
  516.  
  517. '(Be careful with the length of the item fields. The Insert key and the QB
  518. 'Cut + Paste feature really come in handy for this kind of editing)
  519.  
  520. 'Then we also want to make "First" a trigger item, so we put an underscore
  521. 'before the "F".
  522. 'This is what we end up with:
  523.  
  524. '        VM6% = 6
  525. '        VM6A% = 8
  526. '        VM6$ = " _First   Second   Third    Fourth   Fifth    Sixth   "
  527. '        VM60% = SADD(VM6$)
  528.  
  529. 'Now we simply delete the original VM6 set and cut and paste the new one in
  530. '(remembering to eliminate the comment quotes)
  531. 'If we run the program at this point, our new menu will be there, but its
  532. 'barmenu item will still read "Hellos".  So we change
  533.  
  534. ' BarMenu$ = " English   Italian   German    French    Spanish   Hellos    Quit     "
  535. '
  536. 'to:                                          
  537. '                                                                
  538. ' BarMenu$ = " English   Italian   German    French    Spanish   List      Quit     "
  539. '
  540. 'and we change
  541. '
  542. '    BarMenuKeys$ = "EIGFSHQ"
  543. '
  544. ' to:
  545. '                         
  546. '    BarMenuKeys$ = "EIGFSLQ"
  547. '
  548.  
  549. 'Voilá!  That's all there is to it. But let's take the example a little
  550. 'further, and say that "List" will be the last item on the barmenu. So we
  551. 'delete the VM7 set ("Quit")...
  552. '
  553. '...and we change
  554. '
  555. 'BarNumber% = 7  to  BarNumber% = 6
  556. '
  557. 'and we go back to BarMenuKeys$ and change it to: EIGFSL
  558. '
  559. 'That's all there is to it. Follow these steps and you can customize PULDOWN
  560. 'to your CPU's content, so long as you stay within the stated constraints.
  561.  
  562. '▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  563. 'END NOTES
  564.  
  565. 'PULDOWN's generated menu will always start at Row 1, Column 1. That cannot
  566. 'be changed, except at the source code level. It is, after all, meant to be
  567. 'a main menu. But if there is demand for making the starting position a
  568. 'variable, I might be talked into it.
  569.  
  570. 'The sum of all the characters and spaces in all the pulldown menus
  571. 'cannot exceed 1000. This is the equivalent of seven pulldown menus, each
  572. 'ten lines deep and 13 characters wide. That's large enough to go beyond
  573. 'practicality. But if you should get to the point where you need to figure out
  574. 'precisely how many bytes your menu takes, here's how to do it:
  575. '
  576. '       In each pulldown set, add 1 to the VMnA% variable, then multiply
  577. '       it by the VMn1% variable.
  578. '
  579. '       Repeat this procedure for each set, then add them up.
  580. '
  581. '       Example: (VM1A% + 1) * VM1%
  582. '                ( 11   + 1) * 4    = 48
  583. '               Repeating this step with each VM set and adding the results
  584. '               yields 378 for the current set of pulldowns.
  585.  
  586. 'There may be occasions when, after the user has selected a menu item, you
  587. 'want to keep the barmenu at the top of the screen, and the "active" barmenu
  588. 'item in reverse color, just as QuickBASIC does when you select something
  589. 'from the "File" menu. PULDOWN cannot do this for you, because it's finished.
  590. 'You must overwrite the barmenu item with LOCATE, COLOR and PRINT commands.
  591.  
  592. 'PULDOWN disables the Ctrl+C feature while it is in effect, so the user cannot
  593. 'blow the menu and the whole program. The only way to get out of the menu is
  594. 'to select an item or press ESC. However, when running in QB, Ctrl+Break
  595. 'will return you to the environment.
  596.  
  597. 'COLOR MIX TABLE (partial):
  598.  
  599. '       Blue on Yellow          97
  600. '       Yellow on Blue          22
  601.  
  602. '       Bright blue on yellow   105
  603. '       Bright yellow on blue   22
  604.  
  605. '       Bright blue on red      73
  606. '       Bright red on blue      28
  607.  
  608. '       Magenta on green        45
  609. '       Green on magenta        90
  610.  
  611. '       Red on white            124
  612. '       White on red            79
  613.  
  614. '       Blue on white           113          
  615. '       White on blue           23
  616.  
  617. '       Bright blue on white    121             'default setting
  618. '       Bright white on blue    31
  619.  
  620. '       etc.
  621.  
  622. 'EOF
  623.  
  624.