home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / S12780.ZIP / UIDEMO.BAS < prev    next >
BASIC Source File  |  1990-10-25  |  46KB  |  1,262 lines

  1. ' ===========================================================================
  2. '
  3. ' UIDEMO.BAS Copyright (c) 1989-1990 Microsoft Corporation
  4. '
  5. ' ===========================================================================
  6. ' ===========================================================================
  7. ' Decls, includes, and dimensions
  8. ' ===========================================================================
  9. DEFINT A-Z
  10. DECLARE SUB AboutDemo ()
  11. DECLARE SUB AboutUIP ()
  12. DECLARE SUB AboutMouse ()
  13. DECLARE SUB AboutAccess ()
  14. DECLARE SUB AboutQuick ()
  15. DECLARE SUB AboutWindows ()
  16. DECLARE SUB ColorDisplay ()
  17. DECLARE SUB DemoAlert ()
  18. DECLARE SUB DemoDialog ()
  19. DECLARE SUB DemoDialogEZ ()
  20. DECLARE SUB DemoFileNameListBox ()
  21. DECLARE SUB DemoListBox ()
  22. DECLARE SUB DemoWindow ()
  23. DECLARE SUB DemoScrollBar ()
  24. DECLARE SUB DemoResize ()
  25. DECLARE SUB MonoDisplay ()
  26. DECLARE SUB SetupDesktop ()
  27. DECLARE SUB SetupMenu ()
  28. DECLARE FUNCTION GetFileCount% (FileSpec$)
  29.  
  30. '$INCLUDE: 'general.bi'
  31. '$INCLUDE: 'mouse.bi'
  32. '$INCLUDE: 'menu.bi'
  33. '$INCLUDE: 'window.bi'
  34.  
  35. COMMON SHARED /uitools/ GloMenu           AS MenuMiscType
  36. COMMON SHARED /uitools/ GloTitle()        AS MenuTitleType
  37. COMMON SHARED /uitools/ GloItem()         AS MenuItemType
  38. COMMON SHARED /uitools/ GloWindow()       AS windowType
  39. COMMON SHARED /uitools/ GloButton()       AS buttonType
  40. COMMON SHARED /uitools/ GloEdit()         AS EditFieldType
  41. COMMON SHARED /uitools/ GloStorage        AS WindowStorageType
  42. COMMON SHARED /uitools/ GloWindowStack()  AS INTEGER
  43. COMMON SHARED /uitools/ GloBuffer$()
  44.  
  45. DIM GloTitle(MAXMENU)           AS MenuTitleType
  46. DIM GloItem(MAXMENU, MAXITEM)   AS MenuItemType
  47. DIM GloWindow(MAXWINDOW)        AS windowType
  48. DIM GloButton(MAXBUTTON)        AS buttonType
  49. DIM GloEdit(MAXEDITFIELD)       AS EditFieldType
  50. DIM GloWindowStack(MAXWINDOW)   AS INTEGER
  51. DIM GloBuffer$(MAXWINDOW + 1, 2)
  52.  
  53. DIM SHARED DisplayType          AS INTEGER
  54.  
  55.     ' =======================================================================
  56.     ' Initialize Demo
  57.     ' =======================================================================
  58.  
  59.     MenuInit
  60.     WindowInit
  61.     MouseShow
  62.     MonoDisplay
  63.  
  64.     ' =======================================================================
  65.     ' Show Opening alert window
  66.     ' =======================================================================
  67.  
  68.          
  69.          a$ = "User Interface Toolbox Demo|"
  70.     a$ = a$ + "for|"
  71.     a$ = a$ + "Microsoft BASIC 7.1 Professional Development System|"
  72.     a$ = a$ + "Copyright (c) 1989-1990 Microsoft Corporation|"
  73.  
  74.     x = Alert(4, a$, 9, 10, 14, 70, "Color", "Monochrome", "")
  75.  
  76.     IF x = 1 THEN
  77.         DisplayType = TRUE
  78.         ColorDisplay
  79.     END IF
  80.  
  81.     ' =======================================================================
  82.     ' Main Loop : Stay in loop until DemoFinished set to TRUE
  83.     ' =======================================================================
  84.  
  85.     DemoFinished = FALSE
  86.  
  87.     WHILE NOT DemoFinished
  88.         kbd$ = MenuInkey$
  89.         WHILE MenuCheck(2)
  90.             GOSUB MenuTrap
  91.         WEND
  92.     WEND
  93.  
  94.     ' =======================================================================
  95.     ' End Program
  96.     ' =======================================================================
  97.  
  98.     MouseHide
  99.     COLOR 15, 0
  100.     CLS
  101.     END
  102.  
  103.  
  104.  
  105. ' ===========================================================================
  106. ' If a menu event occured, call the proper demo, or if Exit, set demoFinished
  107. ' ===========================================================================
  108.  
  109. MenuTrap:
  110.     menu = MenuCheck(0)
  111.     item = MenuCheck(1)
  112.    
  113.     SELECT CASE menu
  114.         CASE 1
  115.             SELECT CASE item
  116.                 CASE 1:  DemoAlert
  117.                 CASE 2:  DemoDialogEZ
  118.                 CASE 3:  DemoDialog
  119.                 CASE 4:  DemoListBox
  120.                 CASE 5:  DemoFileNameListBox
  121.                 CASE 6:  DemoScrollBar
  122.                 CASE 7:  DemoWindow
  123.                 CASE 8:  DemoResize
  124.                 CASE 10: DemoFinished = TRUE
  125.             END SELECT
  126.         CASE 2
  127.             SELECT CASE item
  128.                 CASE 1: ColorDisplay
  129.                 CASE 2: MonoDisplay
  130.                 
  131.             END SELECT
  132.         CASE 3
  133.             SELECT CASE item
  134.                 CASE 1: AboutDemo
  135.                 CASE 2: AboutUIP
  136.                 CASE 3: AboutWindows
  137.                 CASE 4: AboutMouse
  138.                 CASE 5: AboutAccess
  139.                 CASE 6: AboutQuick
  140.             END SELECT
  141.         CASE ELSE
  142.     END SELECT
  143. RETURN
  144.  
  145. SUB AboutAccess
  146.          a$ = "                      Access Keys||"
  147.     a$ = a$ + "Access keys are the keys on the menu bar that are highlighted|"
  148.     a$ = a$ + "when you press the Alt key. If you press a letter that is|"
  149.     a$ = a$ + "highlighted in a menu title, that menu will be selected.||"
  150.     a$ = a$ + "Once a pull-down menu is displayed, each menu item also has a|"
  151.     a$ = a$ + "highlighted letter associated with each choice. Press the|"
  152.     a$ = a$ + "letter that corresponds to the menu item you want to select.||"
  153.     a$ = a$ + "If, after you press Alt, you change your mind, press the Alt|"
  154.     a$ = a$ + "key again to cancel."
  155.    
  156.     junk = Alert(1, a$, 7, 9, 20, 69, "", "", "")
  157.  
  158. END SUB
  159.  
  160. SUB AboutDemo
  161.          a$ = "                      About This Demo||"
  162.     a$ = a$ + "Running this program provides a visual demonstration of most|"
  163.     a$ = a$ + "of the features implemented in the new User Interface Toolbox|"
  164.     a$ = a$ + "for the BASIC Compiler 7.1.||"
  165.     a$ = a$ + "In addition to serving as a demo of toolbox features, the|"
  166.     a$ = a$ + "source code that makes up this program can also serve as a|"
  167.     a$ = a$ + "programming example of how to implement these features in|"
  168.     a$ = a$ + "your programs. While the demo is relatively simple, it does|"
  169.     a$ = a$ + "illustrate almost all the features available."
  170.     
  171.     junk = Alert(1, a$, 7, 9, 19, 69, "", "", "")
  172. END SUB
  173.  
  174. SUB AboutMouse
  175.          a$ = "                      Using the Mouse||"
  176.     a$ = a$ + "Virtually all operations in the User Interface Toolbox can|"
  177.     a$ = a$ + "be accomplished using the mouse. Move the mouse cursor to|"
  178.     a$ = a$ + "whatever you want to select and press the left button.||"
  179.     a$ = a$ + "In addition to being able to make a choice with a mouse,|"
  180.     a$ = a$ + "you can also perform a number of operations on windows.|"
  181.     a$ = a$ + "Using the mouse you can close, move, or resize windows|"
  182.     a$ = a$ + "depending on the particular features of the window that is|"
  183.     a$ = a$ + "active."
  184.    
  185.     junk = Alert(1, a$, 7, 9, 19, 69, "", "", "")
  186.  
  187. END SUB
  188.  
  189. SUB AboutQuick
  190.          a$ = "                      Quick Keys||"
  191.     a$ = a$ + "Quick keys are optional keys that you can define in addition|"
  192.     a$ = a$ + "to the normal access keys that must be specified when you|"
  193.     a$ = a$ + "set up the individual menu items.||"
  194.     a$ = a$ + "Quick keys normally reduce selection of a menu item to one|"
  195.     a$ = a$ + "keystroke. For example, this demo uses function keys F1 thru|"
  196.     a$ = a$ + "F8 to select menu choices that demonstrate different features|"
  197.     a$ = a$ + "of the User Interface Toolbox.  Additionally, Ctrl-X is the|"
  198.     a$ = a$ + "Quick key that exits this demonstration program."
  199.    
  200.     junk = Alert(1, a$, 7, 9, 19, 69, "", "", "")
  201.  
  202. END SUB
  203.  
  204. SUB AboutUIP
  205.          a$ = "                 About the User Interface||"
  206.     a$ = a$ + "The user interface provided with this toolbox is designed to|"
  207.     a$ = a$ + "provide much the same functionality as that found in the QBX|"
  208.     a$ = a$ + "programming environment. The menus, check boxes, option|"
  209.     a$ = a$ + "buttons, and other interface features operate similarly to|"
  210.     a$ = a$ + "their QBX counterparts. ||"
  211.     a$ = a$ + "If you know how to navigate QBX, you know how to navigate|"
  212.     a$ = a$ + "the interface provided by the User Interface Toolbox."
  213.    
  214.     junk = Alert(1, a$, 7, 9, 18, 69, "", "", "")
  215. END SUB
  216.  
  217. SUB AboutWindows
  218.          a$ = "                     About the Windows||"
  219.     a$ = a$ + "Several border characters used by the windows in the User|"
  220.     a$ = a$ + "Interface Toolbox have special significance.  Any window that|"
  221.     a$ = a$ + "has a '=' in the upper-left corner can be closed by selecting|"
  222.     a$ = a$ + "that character with the mouse. Windows with the '░' character|"
  223.     a$ = a$ + "across the window's top row can be moved around the screen by|"
  224.     a$ = a$ + "selecting that area with the mouse.  The '+' character in the|"
  225.     a$ = a$ + "lower-right corner means that the window can be resized by|"
  226.     a$ = a$ + "selecting the '+' character with the mouse.||"
  227.     a$ = a$ + "Note that none of these features can be accessed without a|"
  228.     a$ = a$ + "mouse. "
  229.  
  230.     junk = Alert(1, a$, 7, 9, 21, 69, "", "", "")
  231.  
  232. END SUB
  233.  
  234. SUB ColorDisplay
  235.     DisplayType = TRUE
  236.     MouseHide
  237.     SetupMenu
  238.     MenuSetState 2, 1, 2
  239.     MenuSetState 2, 2, 1
  240.     SetupDesktop
  241.     MenuShow
  242.     MouseShow
  243. END SUB
  244.  
  245. SUB DemoAlert
  246.  
  247.     ' =======================================================================
  248.     ' Simple little demo of how easy alerts are to use.
  249.     ' =======================================================================
  250.  
  251.          a$ = "|"
  252.     a$ = a$ + "This is an Alert Box.| |"
  253.     a$ = a$ + "It was created using a simple one|"
  254.     a$ = a$ + "line command.  Notice the buttons|"
  255.     a$ = a$ + "below.  They are user definable|"
  256.     a$ = a$ + "yet their spacing is automatic."
  257.  
  258.     B$ = "You Selected OK"
  259.  
  260.     C$ = "You Selected Cancel"
  261.  
  262.     SELECT CASE Alert(4, a$, 6, 20, 15, 60, "OK", "Cancel", "")
  263.         CASE 1
  264.             x = Alert(4, B$, 10, 25, 12, 55, "OK", "", "")
  265.         CASE 2
  266.             x = Alert(4, C$, 10, 25, 12, 55, "OK", "", "")
  267.     END SELECT
  268.  
  269. END SUB
  270.  
  271. SUB DemoDialog
  272.  
  273.     ' =======================================================================
  274.     ' This is about as complex as they get.  As you can see it is still very
  275.     ' simple - just a lot bigger.  This sub exactly duplicates the
  276.     ' functionality of the QuickBASIC Search-Change dialog box.
  277.     ' =======================================================================
  278.  
  279.     ' =======================================================================
  280.     ' Open Window, place a horizontal line on row 13
  281.     ' =======================================================================
  282.  
  283.     WindowOpen 1, 6, 11, 19, 67, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 1, ""
  284.  
  285.     WindowLine 13
  286.  
  287.     ' =======================================================================
  288.     ' Print the text, and boxes for the edit fields
  289.     ' =======================================================================
  290.  
  291.     WindowLocate 2, 2
  292.     WindowPrint 2, "Find What:"
  293.     WindowBox 1, 14, 3, 56
  294.  
  295.     WindowLocate 5, 2
  296.     WindowPrint 2, "Change To:"
  297.     WindowBox 4, 14, 6, 56
  298.  
  299.  
  300.     ' =======================================================================
  301.     ' Print the title of the window -- This overides the string in WindowOpen
  302.     ' =======================================================================
  303.  
  304.     WindowLocate 0, 26
  305.     WindowPrint 1, " Change "
  306.  
  307.     WindowBox 8, 32, 12, 56
  308.  
  309.     ' =======================================================================
  310.     ' Open Edit fields
  311.     ' =======================================================================
  312.  
  313.     search$ = ""
  314.     replace$ = ""
  315.     EditFieldOpen 1, search$, 2, 15, 0, 0, 40, 39
  316.  
  317.     EditFieldOpen 2, replace$, 5, 15, 0, 0, 40, 39
  318.  
  319.     ' =======================================================================
  320.     ' Open all buttons
  321.     ' =======================================================================
  322.  
  323.     ButtonOpen 1, 1, "Match Upper/Lowercase", 9, 2, 0, 0, 2
  324.     ButtonOpen 2, 1, "Whole Word", 10, 2, 0, 0, 2
  325.     ButtonOpen 3, 1, "1. Active Window", 9, 34, 0, 0, 3
  326.     ButtonOpen 4, 2, "2. Current Module", 10, 34, 0, 0, 3
  327.     ButtonOpen 5, 1, "3. All Modules", 11, 34, 0, 0, 3
  328.     ButtonOpen 6, 2, "Find and Verify", 14, 2, 0, 0, 1
  329.     ButtonOpen 7, 1, "Change All", 14, 22, 0, 0, 1
  330.     ButtonOpen 8, 1, "Cancel", 14, 38, 0, 0, 1
  331.     ButtonOpen 9, 1, "Help", 14, 49, 0, 0, 1
  332.  
  333.     ' =======================================================================
  334.     ' Set initial states to match initial button settings
  335.     ' =======================================================================
  336.  
  337.     MatchState = FALSE
  338.     WordState = FALSE
  339.     searchState = 2
  340.     pushButton = 1
  341.     currButton = 0
  342.     currEditField = 1
  343.  
  344.     ' =======================================================================
  345.     ' Do until exitFlag is set
  346.     ' =======================================================================
  347.  
  348.     ExitFlag = FALSE
  349.     WHILE NOT ExitFlag
  350.         WindowDo currButton, currEditField
  351.         SELECT CASE Dialog(0)
  352.             CASE 0, 3, 4, 5, 20
  353.  
  354.             ' ==============================================================
  355.             ' If edit field clicked, assign currEditField to Dialog(2)
  356.             ' ==============================================================
  357.  
  358.             CASE 2
  359.                 currButton = 0
  360.                 currEditField = Dialog(2)
  361.  
  362.             ' ==============================================================
  363.             ' If escape is hit,  set pushbutton = 0 and exit flag
  364.             ' ==============================================================
  365.  
  366.             CASE 9  '(Escape)
  367.                 pushButton = 3
  368.                 ExitFlag = TRUE
  369.                
  370.             ' ==============================================================
  371.             ' If return is hit, perform action based on the current button
  372.             ' Button 9 is the help button.  In that case, show help, else just
  373.             ' exit
  374.             ' ==============================================================
  375.  
  376.             CASE 6
  377.                 SELECT CASE currButton
  378.                     CASE 9
  379.                         a$ = "Sample Help Window"
  380.                         ButtonSetState pushButton + 5, 1
  381.                         pushButton = 4
  382.                         ButtonSetState pushButton + 5, 2
  383.                         junk = Alert(4, a$, 7, 9, 19, 69, "", "", "")
  384.                     CASE ELSE
  385.                         ExitFlag = TRUE
  386.                 END SELECT
  387.  
  388.  
  389.             ' ==============================================================
  390.             ' A Button was pushed with mouse. Perform the desired action
  391.             ' based on Button
  392.             ' ==============================================================
  393.  
  394.             CASE 1
  395.                 currButton = Dialog(1)
  396.                 currEditField = 0
  397.                 SELECT CASE currButton
  398.                     CASE 1
  399.                         MatchState = NOT MatchState
  400.                         ButtonToggle 1
  401.                     CASE 2
  402.                         WordState = NOT WordState
  403.                         ButtonToggle 2
  404.                     CASE 3, 4, 5
  405.                         ButtonSetState searchState + 2, 1
  406.                         searchState = Dialog(1) - 2
  407.                         ButtonSetState searchState + 2, 2
  408.                     CASE 6, 7, 8
  409.                         pushButton = Dialog(1) - 5
  410.                         ExitFlag = TRUE
  411.                     CASE 9
  412.                         a$ = "Sample Help Window"
  413.                         ButtonSetState pushButton + 5, 1
  414.                         pushButton = Dialog(1) - 5
  415.                         ButtonSetState pushButton + 5, 2
  416.                         junk = Alert(4, a$, 7, 9, 19, 69, "", "", "")
  417.                     CASE ELSE
  418.                 END SELECT
  419.  
  420.  
  421.             ' ==============================================================
  422.             ' Tab was hit.  Depending upon the current button, or current edit field,
  423.             ' assign the new values to currButton, and currEditField
  424.             ' ==============================================================
  425.  
  426.             CASE 7  'tab
  427.                 SELECT CASE currButton
  428.                     CASE 0
  429.                         SELECT CASE currEditField
  430.                             CASE 1
  431.                                 currEditField = 2
  432.                           
  433.                             CASE ELSE
  434.                                 currButton = 1
  435.                                 currEditField = 0
  436.                         END SELECT
  437.                     CASE 1
  438.                         currButton = 2
  439.                     CASE 6, 7, 8
  440.                         currButton = currButton + 1
  441.                         ButtonSetState pushButton + 5, 1
  442.                         pushButton = currButton - 5
  443.                         ButtonSetState pushButton + 5, 2
  444.                     CASE 3, 4, 5
  445.                         currButton = 6
  446.                     CASE 2
  447.                         currButton = 2 + searchState
  448.                     CASE 9
  449.                         currButton = 0
  450.                         ButtonSetState pushButton + 5, 1
  451.                         pushButton = 1
  452.                         ButtonSetState pushButton + 5, 2
  453.                         currEditField = 1
  454.                 END SELECT
  455.  
  456.  
  457.             ' ==============================================================
  458.             ' Same for Back Tab, only reverse.
  459.             ' ==============================================================
  460.  
  461.             CASE 8 'back tab
  462.                 SELECT CASE currButton
  463.                     CASE 0
  464.                         SELECT CASE currEditField
  465.                             CASE 1
  466.                                 currButton = 9
  467.                                 ButtonSetState pushButton + 5, 1
  468.                                 pushButton = currButton - 5
  469.                                 ButtonSetState pushButton + 5, 2
  470.                                 currEditField = 0
  471.                             CASE 2
  472.                                 currEditField = 1
  473.                         END SELECT
  474.                     CASE 1
  475.                         currButton = 0
  476.                         currEditField = 2
  477.                     CASE 7, 8, 9
  478.                         currButton = currButton - 1
  479.                         ButtonSetState pushButton + 5, 1
  480.                         pushButton = currButton - 5
  481.                         ButtonSetState pushButton + 5, 2
  482.                     CASE 3, 4, 5
  483.                         currButton = 2
  484.                     CASE 6
  485.                         currButton = 2 + searchState
  486.                     CASE 2
  487.                         currButton = 1
  488.                 END SELECT
  489.  
  490.  
  491.             ' ==============================================================
  492.             ' Up arrow only affects buttons 1,2,3,4,5  (the radial and check
  493.             ' buttons)
  494.             ' ==============================================================
  495.  
  496.             CASE 10 'up arrow
  497.                 SELECT CASE currButton
  498.                     CASE 1
  499.                         IF NOT MatchState THEN
  500.                             MatchState = TRUE
  501.                             ButtonToggle 1
  502.                         END IF
  503.                     CASE 2
  504.                         IF NOT WordState THEN
  505.                             WordState = TRUE
  506.                             ButtonToggle 2
  507.                         END IF
  508.                     CASE 3
  509.                         ButtonSetState searchState + 2, 1
  510.                         searchState = 3
  511.                         currButton = 5
  512.                         ButtonSetState searchState + 2, 2
  513.                     CASE 4, 5
  514.                         ButtonSetState searchState + 2, 1
  515.                         searchState = searchState - 1
  516.                         currButton = currButton - 1
  517.                         ButtonSetState searchState + 2, 2
  518.                 END SELECT
  519.               
  520.  
  521.             ' ==============================================================
  522.             ' Same with down arrow, only reverse
  523.             ' ==============================================================
  524.  
  525.             CASE 11 'down
  526.                 SELECT CASE currButton
  527.                     CASE 1
  528.                         IF MatchState THEN
  529.                             MatchState = NOT MatchState
  530.                             ButtonToggle 1
  531.                         END IF
  532.                     CASE 2
  533.                         IF WordState THEN
  534.                             WordState = NOT WordState
  535.                             ButtonToggle 2
  536.                         END IF
  537.                     CASE 3, 4
  538.                         ButtonSetState searchState + 2, 1
  539.                         searchState = searchState + 1
  540.                         currButton = currButton + 1
  541.                         ButtonSetState searchState + 2, 2
  542.                     CASE 5
  543.                         ButtonSetState searchState + 2, 1
  544.                         searchState = 1
  545.                         currButton = 3
  546.                         ButtonSetState searchState + 2, 2
  547.                 END SELECT
  548.            
  549.             ' ==============================================================
  550.             ' Left arrow only affects button 1 and 2  (the check buttons)
  551.             ' ==============================================================
  552.  
  553.             CASE 12 'Left Arrow
  554.                SELECT CASE currButton
  555.                     CASE 1
  556.                         IF NOT MatchState THEN
  557.                             MatchState = TRUE
  558.                             ButtonToggle 1
  559.                         END IF
  560.                     CASE 2
  561.                         IF NOT WordState THEN
  562.                             WordState = TRUE
  563.                             ButtonToggle 2
  564.                         END IF
  565.                     CASE 3
  566.                         ButtonSetState searchState + 2, 1
  567.                         searchState = 3
  568.                         currButton = 5
  569.                         ButtonSetState searchState + 2, 2
  570.  
  571.                     CASE 4, 5
  572.                         ButtonSetState searchState + 2, 1
  573.                         searchState = searchState - 1
  574.                         currButton = currButton - 1
  575.                         ButtonSetState searchState + 2, 2
  576.  
  577.                END SELECT
  578.  
  579.  
  580.             ' ==============================================================
  581.             ' Right arrow only affects button 1 and 2  (the check buttons)
  582.             ' ==============================================================
  583.            
  584.             CASE 13 'Right Arrow
  585.                 SELECT CASE currButton
  586.                     CASE 1
  587.                         IF MatchState THEN
  588.                             MatchState = NOT MatchState
  589.                             ButtonToggle 1
  590.                         END IF
  591.                     CASE 2
  592.                         IF WordState THEN
  593.                             WordState = NOT WordState
  594.                             ButtonToggle 2
  595.                         END IF
  596.                     CASE 3, 4
  597.                         ButtonSetState searchState + 2, 1
  598.                         searchState = searchState + 1
  599.                         currButton = currButton + 1
  600.                         ButtonSetState searchState + 2, 2
  601.                     CASE 5
  602.                         ButtonSetState searchState + 2, 1
  603.                         searchState = 1
  604.                         currButton = 3
  605.                         ButtonSetState searchState + 2, 2
  606.  
  607.                 END SELECT
  608.  
  609.             ' ==============================================================
  610.             ' Space will toggle a check button, or select a push button (including help)
  611.             ' ==============================================================
  612.  
  613.             CASE 14 'space
  614.                 SELECT CASE currButton
  615.                     CASE 1
  616.                         MatchState = NOT MatchState
  617.                         ButtonToggle 1
  618.                     CASE 2
  619.                         WordState = NOT WordState
  620.                         ButtonToggle 2
  621.                     CASE 6, 7, 8
  622.                         pushButton = currButton - 5
  623.                         ExitFlag = TRUE
  624.                     CASE 9
  625.                         a$ = "Sample Help Window"
  626.                         ButtonSetState pushButton + 5, 1
  627.                         pushButton = 4
  628.                         ButtonSetState pushButton + 5, 2
  629.                         junk = Alert(4, a$, 7, 9, 19, 69, "", "", "")
  630.                     CASE ELSE
  631.                 END SELECT
  632.             CASE ELSE
  633.         END SELECT
  634.     WEND
  635.  
  636.  
  637.     ' =======================================================================
  638.     ' Prepare data for final alert box that says what the final state was.
  639.     ' =======================================================================
  640.   
  641.     search$ = EditFieldInquire(1)
  642.     replace$ = EditFieldInquire(2)
  643.  
  644.    
  645.     WindowClose 1
  646.     IF pushButton = 3 THEN
  647.         a$ = "You Selected CANCEL"
  648.         x = Alert(4, a$, 10, 25, 12, 55, "OK", "", "")
  649.     ELSE
  650.         IF pushButton = 1 THEN
  651.             a$ = "You selected VERIFY.  Here are your other selections:| |"
  652.         ELSE
  653.             a$ = "You selected CHANGE ALL.  Here are your other selections:| |"
  654.         END IF
  655.  
  656.         IF MatchState THEN
  657.             a$ = a$ + "   Match Upper/Lowercase = Yes|"
  658.         ELSE
  659.             a$ = a$ + "   Match Upper/Lowercase = No|"
  660.         END IF
  661.  
  662.         IF WordState THEN
  663.             a$ = a$ + "   Whole Word            = Yes|"
  664.         ELSE
  665.             a$ = a$ + "   Whole Word            = No|"
  666.         END IF
  667.  
  668.         SELECT CASE searchState
  669.             CASE 1: a$ = a$ + "   Search space          = Active Window|"
  670.             CASE 2: a$ = a$ + "   Search space          = Current Module|"
  671.             CASE 3: a$ = a$ + "   Search space          = All Modules|"
  672.         END SELECT
  673.  
  674.         a$ = a$ + "   Search string : " + search$ + "|"
  675.         a$ = a$ + "   Replace string: " + replace$ + "|"
  676.        
  677.         x = Alert(2, a$, 7, 11, 15, 69, "OK", "", "")
  678.     END IF
  679. END SUB
  680.  
  681. SUB DemoDialogEZ
  682.  
  683.  
  684.     ' =======================================================================
  685.     ' Open Window, write text, and open button and edit field
  686.     ' =======================================================================
  687.  
  688.     WindowOpen 1, 8, 20, 13, 60, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 1, ""
  689.    
  690.     WindowLocate 2, 2
  691.     WindowPrint 2, "Your Name:"
  692.     WindowBox 1, 14, 3, 38
  693.  
  694.     EditFieldOpen 1, "", 2, 15, 0, 0, 23, 22
  695.     WindowLine 5
  696.     ButtonOpen 1, 2, "OK", 6, 17, 0, 0, 1
  697.  
  698.  
  699.     ' =======================================================================
  700.     ' Set initial state + go into main loop
  701.     ' =======================================================================
  702.  
  703.     currButton = 0
  704.     currEditField = 1
  705.  
  706.     ExitFlag = FALSE
  707.    
  708.     WHILE NOT ExitFlag
  709.         WindowDo currButton, currEditField
  710.         SELECT CASE Dialog(0)
  711.             CASE 1, 6                       'Button, or Enter, exit loop
  712.                 ExitFlag = TRUE
  713.             CASE 2                          'EditField, switch to edit field
  714.                 currButton = 0
  715.                 currEditField = 1
  716.             CASE 7, 8                       'tab and backTab, flip/flop state
  717.                 IF currButton = 1 THEN
  718.                     currButton = 0
  719.                     currEditField = 1
  720.                 ELSE
  721.                     currButton = 1
  722.                     currEditField = 0
  723.                 END IF
  724.             CASE 14                         'space - if on button then exit
  725.                 IF currButton = 1 THEN
  726.                     ExitFlag = TRUE
  727.                 END IF
  728.             CASE 9                          'escape
  729.                 WindowClose 1
  730.                 EXIT SUB
  731.             CASE ELSE
  732.         END SELECT
  733.     WEND
  734.  
  735.     ' =======================================================================
  736.     ' Assign the variable before closing the window, and close the window
  737.     ' =======================================================================
  738.  
  739.     yourName$ = EditFieldInquire$(1)
  740.  
  741.     WindowClose 1
  742.    
  743.     IF LEN(yourName$) <> 0 THEN
  744.         junk = Alert(4, "Hello " + yourName$ + ".", 10, 20, 12, 60, "OK", "", "")
  745.     ELSE
  746.         junk = Alert(4, "I understand. You wish to remain anonymous!", 10, 15, 12, 65, "OK", "", "")
  747.     END IF
  748.     
  749. END SUB
  750.  
  751. SUB DemoFileNameListBox
  752.     
  753.     WindowOpen 1, 8, 20, 15, 60, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, TRUE, 1, ""
  754.  
  755.     WindowLocate 2, 4
  756.     WindowPrint 4, "Enter a file specification:"
  757.     WindowBox 3, 4, 5, 38
  758.  
  759.     EditFieldOpen 1, "*.*", 4, 5, 0, 0, 23, 22
  760.     WindowLine 7
  761.     ButtonOpen 1, 2, "OK", 8, 17, 0, 0, 1
  762.  
  763.     ' =======================================================================
  764.     ' Set initial state + go into main loop
  765.     ' =======================================================================
  766.  
  767.     currButton = 0
  768.     currEditField = 1
  769.    
  770.     ExitFlag = FALSE
  771.     WHILE NOT ExitFlag
  772.         WindowDo currButton, currEditField
  773.         SELECT CASE Dialog(0)
  774.             CASE 1, 6                       'Button, or Enter, exit loop
  775.                 ExitFlag = TRUE
  776.             CASE 2                          'EditField, switch to edit field
  777.                 currButton = 0
  778.                 currEditField = 1
  779.             CASE 7, 8                       'tab and backTab, flip/flop state
  780.                 IF currButton = 1 THEN
  781.                     currButton = 0
  782.                     currEditField = 1
  783.                 ELSE
  784.                     currButton = 1
  785.                     currEditField = 0
  786.                 END IF
  787.             CASE 9                          'escape
  788.                 WindowClose 1
  789.                 EXIT SUB
  790.             CASE 14                         'space - if on button then exit
  791.                 IF currButton = 1 THEN
  792.                     ExitFlag = TRUE
  793.                 END IF
  794.             CASE ELSE
  795.         END SELECT
  796.     WEND
  797.  
  798.     ' =======================================================================
  799.     ' Assign the variable before closing the window, and close the window
  800.     ' =======================================================================
  801.  
  802.     FileSpec$ = EditFieldInquire$(1)
  803.  
  804.     ' =======================================================================
  805.     ' Make sure its a valid file name
  806.     ' =======================================================================
  807.  
  808.     delimit = INSTR(FileSpec$, ".")
  809.  
  810.     IF delimit THEN
  811.         fileName$ = LEFT$(FileSpec$, delimit - 1)
  812.         fileExt$ = RIGHT$(FileSpec$, LEN(FileSpec$) - (delimit))
  813.     ELSE
  814.         fileName$ = FileSpec$
  815.         fileExt$ = ""
  816.     END IF
  817.  
  818.     IF LEN(FileSpec$) = 0 OR LEN(fileName$) > 8 OR LEN(fileExt$) > 3 THEN
  819.         WindowClose 1
  820.         junk = Alert(4, "You didn't enter a valid file specification.", 10, 15, 12, 62, "OK", "", "")
  821.         EXIT SUB
  822.     END IF
  823.  
  824.     FileCount = GetFileCount(FileSpec$)
  825.  
  826.     IF FileCount THEN
  827.  
  828.         REDIM FileList$(FileCount)
  829.  
  830.     ELSE
  831.  
  832.         WindowClose 1
  833.         junk = Alert(4, "No match to your file specification could be found.", 10, 10, 12, 70, "OK", "", "")
  834.         EXIT SUB
  835.     END IF
  836.    
  837.     FileList$(1) = DIR$(FileSpec$)
  838.    
  839.     FOR Indx = 2 TO FileCount
  840.         FileList$(Indx) = DIR$
  841.     NEXT Indx
  842.    
  843.     x = ListBox(FileList$(), UBOUND(FileList$))
  844.  
  845.     SELECT CASE x
  846.         CASE 0
  847.             junk = Alert(4, "You selected CANCEL", 10, 25, 12, 55, "OK", "", "")
  848.         CASE ELSE
  849.             junk = Alert(4, "You selected " + FileList$(x), 10, 25, 12, 55, "OK", "", "")
  850.     END SELECT
  851.  
  852.     WindowClose 1
  853. END SUB
  854.  
  855. SUB DemoListBox
  856.  
  857.     REDIM x$(30), y$(30)
  858.  
  859.     x$(1) = "Orange":                 y$(1) = "Orange you glad I didn't say Banana?"
  860.     x$(2) = "Butter":                 y$(2) = "Try margarine! less cholesterol"
  861.     x$(3) = "Corn":                   y$(3) = "Some people call it maize."
  862.     x$(4) = "Potato":                 y$(4) = "Wouldn't you prefer stuffing?"
  863.     x$(5) = "Grape":                  y$(5) = "Grape balls of fire!"
  864.     x$(6) = "Cherry":                 y$(6) = "Don't chop down the tree!"
  865.     x$(7) = "Lettuce":                y$(7) = "Two heads are better than one."
  866.     x$(8) = "Lima bean":              y$(8) = "Who's Lima? and why do I have her beans?"
  867.     x$(9) = "Carrot":                 y$(9) = "What's up Doc?"
  868.     x$(10) = "Rice":                  y$(10) = "Yes, but can you use chopsticks?"
  869.     x$(11) = "Steak":                 y$(11) = "Ooo.. Big spender."
  870.     x$(12) = "Meatloaf":              y$(12) = "It must be Thursday."
  871.     x$(13) = "Stuffing":              y$(13) = "Wouldn't you prefer potatoes?"
  872.     x$(14) = "Wine":                  y$(14) = "Remember: 'Party Responsibly.'"
  873.     x$(15) = "Pea":                   y$(15) = "Comes with the princess."
  874.     x$(16) = "Gravy":                 y$(16) = "like home made! (Only no lumps)"
  875.     x$(17) = "Pancake":               y$(17) = "Three for a dollar!"
  876.     x$(18) = "Waffle":                y$(18) = "Syrup on your waffle sir?"
  877.     x$(19) = "Broccoli":              y$(19) = "Little trees..."
  878.     x$(20) = "Oatmeal":               y$(20) = "Yuck.."
  879.                             
  880.     x = ListBox(x$(), 20)
  881.  
  882.     SELECT CASE x
  883.         CASE 0
  884.             y = Alert(4, "You Selected Cancel", 10, 25, 12, 55, "OK", "", "")
  885.         CASE ELSE
  886.             y = Alert(4, y$(x), 10, 38 - LEN(y$(x)) \ 2, 12, 43 + LEN(y$(x)) \ 2, "OK", "", "")
  887.     END SELECT
  888.  
  889. END SUB
  890.  
  891. SUB DemoResize
  892.  
  893.     ' =======================================================================
  894.     ' Define Window's text string
  895.     ' =======================================================================
  896.  
  897.     REDIM x$(19)
  898.     x$(1) = "Resize Me!  Hello there!  Welcome to the wonderful world"
  899.     x$(2) = "of Windows.  This demo shows how BASIC programmers can"
  900.     x$(3) = "use a re-sizable window in their own applications."
  901.     x$(4) = ""
  902.     x$(5) = "This demo consists of a single window (this window) which"
  903.     x$(6) = "can be moved, closed, or re-sized.  When the user resizes"
  904.     x$(7) = "a window, an event code of 5 is returned.  Upon receiving"
  905.     x$(8) = "the event code, the programmer can then do whatever is"
  906.     x$(9) = "needed to refresh the window. "
  907.     x$(10) = ""
  908.     x$(11) = "The text in this window simply truncates when the window"
  909.     x$(12) = "is made smaller, but text can be made to wrap either by"
  910.     x$(13) = "character, or at the spaces between words. The choice is"
  911.     x$(14) = "the programmer's."
  912.     x$(15) = ""
  913.     x$(16) = "The programmer has many tools available to make the"
  914.     x$(17) = "job very easy such as functions that return the window"
  915.     x$(18) = "size, and simple one-line calls to perform actions like"
  916.     x$(19) = "opening or closing a window. "
  917.  
  918.  
  919.     ' =======================================================================
  920.     ' Open up a resizeable window
  921.     ' =======================================================================
  922.     
  923.     WindowOpen 1, 4, 5, 4, 16, 0, 7, 0, 7, 8, TRUE, TRUE, TRUE, FALSE, 1, "-Window 1-"
  924.  
  925.     GOSUB DemoResizeDrawText
  926.  
  927.     ExitFlag = FALSE
  928.  
  929.     ' =======================================================================
  930.     ' Process window events...
  931.     '  IMPORTANT:  Window moving, and re-sizing is handled automatically
  932.     '  The window type dictates when this is allowed to happen.
  933.     ' =======================================================================
  934.  
  935.     WHILE NOT ExitFlag
  936.         WindowDo 0, 0
  937.         SELECT CASE Dialog(0)
  938.             CASE 4, 9
  939.                 WindowClose WindowCurrent         'Close current window
  940.                 ExitFlag = TRUE
  941.             CASE 5
  942.                 GOSUB DemoResizeDrawText
  943.             CASE 20
  944.                 ExitFlag = TRUE                   'Exit if menu action
  945.             CASE ELSE
  946.         END SELECT
  947.     WEND
  948.  
  949.     WindowClose 0
  950.  
  951. EXIT SUB
  952.                                                                      
  953. DemoResizeDrawText:
  954.     WindowCls
  955.          
  956.     FOR a = 1 TO 19
  957.         IF a <= WindowRows(1) THEN
  958.             WindowLocate a, 1
  959.             WindowPrint -1, x$(a)
  960.        END IF
  961.     NEXT a
  962. RETURN
  963.  
  964. END SUB
  965.  
  966. SUB DemoScrollBar
  967.  
  968.     ' =======================================================================
  969.     ' Open up a closeable window
  970.     ' =======================================================================
  971.     
  972.     IF NOT DisplayType THEN
  973.         WindowOpen 1, 4, 10, 20, 70, 0, 7, 0, 7, 15, FALSE, TRUE, FALSE, FALSE, 1, "Scroll Bar Demo"
  974.     ELSE
  975.         WindowOpen 1, 4, 10, 20, 70, 15, 5, 15, 5, 14, FALSE, TRUE, FALSE, FALSE, 1, "Scroll Bar Demo"
  976.     END IF
  977.                                
  978.     ButtonOpen 1, 3, "", 4, 4, 14, 4, 6
  979.     ButtonOpen 2, 4, "", 4, 6, 14, 6, 6
  980.     ButtonOpen 3, 5, "", 4, 8, 14, 8, 6
  981.     ButtonOpen 4, 4, "", 4, 10, 14, 10, 6
  982.     ButtonOpen 5, 4, "", 4, 12, 14, 12, 6
  983.     ButtonOpen 6, 9, "", 4, 16, 4, 50, 7
  984.     ButtonOpen 7, 9, "", 6, 16, 6, 50, 7
  985.     ButtonOpen 8, 8, "", 8, 16, 8, 50, 7
  986.     ButtonOpen 9, 10, "", 10, 16, 10, 50, 7
  987.     ButtonOpen 10, 12, "", 12, 16, 12, 50, 7
  988.     ButtonOpen 11, 11, "", 14, 16, 14, 50, 7
  989.  
  990.     ExitFlag = FALSE
  991.  
  992.     ' =======================================================================
  993.     ' Process window events...
  994.     '   IMPORTANT:  Window moving, and re-sizing is handled automatically
  995.     '   The window type dictates when this is allowed to happen.
  996.     ' =======================================================================
  997.  
  998.     WHILE NOT ExitFlag
  999.         WindowDo 0, 0
  1000.         x = Dialog(0)
  1001.  
  1002.         SELECT CASE x
  1003.             CASE 1
  1004.                 button = Dialog(1)
  1005.                
  1006.                 scrollCode = Dialog(19)
  1007.                 currState = ButtonInquire(button)
  1008.  
  1009.                 SELECT CASE scrollCode
  1010.                     CASE -1
  1011.                         IF currState > 1 THEN
  1012.                             newState = currState - 1
  1013.                         END IF
  1014.                     CASE -2
  1015.                         IF currState < MaxScrollLength(button) THEN
  1016.                             newState = currState + 1
  1017.                         END IF
  1018.                     CASE ELSE
  1019.                         newState = scrollCode
  1020.                 END SELECT
  1021.  
  1022.                 ButtonSetState button, newState
  1023.                
  1024.             CASE 4, 9
  1025.                 WindowClose WindowCurrent         'Close current window
  1026.                 ExitFlag = TRUE
  1027.             CASE 20
  1028.                 ExitFlag = TRUE                   'Exit if menu action
  1029.             CASE ELSE
  1030.         END SELECT
  1031.     WEND
  1032.  
  1033.     WindowClose 0
  1034.  
  1035. END SUB
  1036.  
  1037. SUB DemoWindow
  1038.    
  1039.     REDIM z$(4 TO 6, 6)
  1040.  
  1041.     ' =======================================================================
  1042.     ' Open up 6 windows, showcase the features, and make each a different color
  1043.     ' =======================================================================
  1044.     IF NOT DisplayType THEN
  1045.         WindowOpen 1, 6, 5, 12, 25, 0, 7, 0, 7, 15, FALSE, FALSE, FALSE, FALSE, 0, ""
  1046.     ELSE
  1047.         WindowOpen 1, 6, 5, 12, 25, 0, 4, 0, 4, 15, FALSE, FALSE, FALSE, FALSE, 0, ""
  1048.     END IF
  1049.     WindowPrint 1, "Features:"
  1050.     WindowPrint 1, "No Title bar"
  1051.     WindowPrint 1, "No border"
  1052.  
  1053.     IF NOT DisplayType THEN
  1054.         WindowOpen 2, 8, 15, 14, 35, 0, 7, 0, 7, 15, TRUE, FALSE, FALSE, FALSE, 1, "-Window 2-"
  1055.     ELSE
  1056.         WindowOpen 2, 8, 15, 14, 35, 0, 2, 0, 2, 15, TRUE, FALSE, FALSE, FALSE, 1, "-Window 2-"
  1057.     END IF
  1058.     WindowPrint 1, "Features:"
  1059.     WindowPrint 1, "Title bar"
  1060.     WindowPrint 1, "Moveable window"
  1061.     WindowPrint 1, "Single-line border"
  1062.  
  1063.     IF NOT DisplayType THEN
  1064.         WindowOpen 3, 10, 25, 16, 45, 0, 7, 0, 7, 15, FALSE, TRUE, FALSE, FALSE, 1, "-Window 3-"
  1065.     ELSE
  1066.         WindowOpen 3, 10, 25, 16, 45, 0, 3, 0, 3, 15, FALSE, TRUE, FALSE, FALSE, 1, "-Window 3-"
  1067.     END IF
  1068.     WindowPrint 1, "Features:"
  1069.     WindowPrint 1, "Title bar"
  1070.     WindowPrint 1, "Closeable window"
  1071.     WindowPrint 1, "Single-line border"
  1072.  
  1073.     WindowOpen 4, 12, 35, 18, 55, 0, 7, 0, 7, 15, FALSE, FALSE, TRUE, FALSE, 1, "-Window 4-"
  1074.     z$(4, 1) = "Features:"
  1075.     z$(4, 2) = "Title bar"
  1076.     z$(4, 3) = "Resizeable window"
  1077.     z$(4, 4) = "Single-line border"
  1078.     ValidLines = 4
  1079.     GOSUB DemoReDrawText
  1080.  
  1081.     IF NOT DisplayType THEN
  1082.         WindowOpen 5, 14, 45, 20, 65, 0, 7, 0, 7, 15, TRUE, TRUE, TRUE, FALSE, 1, "-Window 5-"
  1083.     ELSE
  1084.         WindowOpen 5, 14, 45, 20, 65, 0, 5, 0, 5, 15, TRUE, TRUE, TRUE, FALSE, 1, "-Window 5-"
  1085.     END IF
  1086.     z$(5, 1) = "Features:"
  1087.     z$(5, 2) = "Title bar"
  1088.     z$(5, 3) = "Moveable window"
  1089.     z$(5, 4) = "Closeable window"
  1090.     z$(5, 5) = "Resizeable window"
  1091.     z$(5, 6) = "Single-line border"
  1092.     ValidLines = 6
  1093.     GOSUB DemoReDrawText
  1094.  
  1095.     IF NOT DisplayType THEN
  1096.         WindowOpen 6, 16, 55, 22, 75, 0, 7, 0, 7, 15, TRUE, TRUE, TRUE, FALSE, 2, "-Window 6-"
  1097.     ELSE
  1098.         WindowOpen 6, 16, 55, 22, 75, 0, 6, 0, 6, 15, TRUE, TRUE, TRUE, FALSE, 2, "-Window 6-"
  1099.     END IF
  1100.     z$(6, 1) = "Features:"
  1101.     z$(6, 2) = "Title bar"
  1102.     z$(6, 3) = "Moveable window"
  1103.     z$(6, 4) = "Closeable window"
  1104.     z$(6, 5) = "Resizeable window"
  1105.     z$(6, 6) = "Double-line border"
  1106.     ValidLines = 6
  1107.     GOSUB DemoReDrawText
  1108.    
  1109.     ' =======================================================================
  1110.     ' Show alert box describing what is going on
  1111.     ' =======================================================================
  1112.  
  1113.          a$ = "WINDOWS:  This demo displays six windows, each representing one "
  1114.     a$ = a$ + "or more of the features that are available.  You may use the "
  1115.     a$ = a$ + "mouse to select windows, move windows, resize windows, or close "
  1116.     a$ = a$ + "windows. You can also select border characters and define your "
  1117.     a$ = a$ + "window title.| |You should know that this demo "
  1118.     a$ = a$ + "consists of only six window open commands, and a 12 line "
  1119.     a$ = a$ + "Select Case statement to handle the actual processing."
  1120.                                            
  1121.     choice = Alert(3, a$, 7, 15, 18, 65, "OK", "Cancel", "")
  1122.  
  1123.     IF choice = 1 THEN
  1124.         ExitFlag = FALSE
  1125.     ELSE
  1126.         ExitFlag = TRUE
  1127.     END IF
  1128.  
  1129.     ' =======================================================================
  1130.     ' Process window events...
  1131.     '  IMPORTANT:  Window moving, and re-sizing is handled automatically
  1132.     '  The windowtype dictates when this is allowed to happen.
  1133.     ' =======================================================================
  1134.  
  1135.     WHILE NOT ExitFlag
  1136.         WindowDo 0, 0
  1137.         SELECT CASE Dialog(0)
  1138.             CASE 3
  1139.                 WindowSetCurrent Dialog(3)        'Change current window
  1140.             CASE 4
  1141.                 WindowClose WindowCurrent         'Close current window
  1142.             CASE 5
  1143.                 GOSUB DemoReDrawText              'Redraw text when resizing
  1144.             CASE 9
  1145.                 ExitFlag = TRUE                   'Exit if escape key pressed
  1146.             CASE 20
  1147.                 ExitFlag = TRUE                   'Exit if menu action
  1148.             CASE ELSE
  1149.         END SELECT
  1150.     WEND
  1151.  
  1152.     WindowClose 0
  1153.  
  1154. EXIT SUB
  1155.  
  1156. DemoReDrawText:
  1157.     WindowCls
  1158.    
  1159.     FOR a = 1 TO ValidLines
  1160.         IF a <= WindowRows(WindowCurrent) THEN
  1161.             WindowLocate a, 1
  1162.             WindowPrint -1, z$(WindowCurrent, a)
  1163.         END IF
  1164.     NEXT a
  1165. RETURN
  1166.  
  1167. END SUB
  1168.  
  1169. FUNCTION GetFileCount (FileSpec$)
  1170.     count = 0
  1171.     fileName$ = DIR$(FileSpec$)
  1172.     DO WHILE fileName$ <> ""
  1173.         count = count + 1
  1174.         fileName$ = DIR$
  1175.     LOOP
  1176.     GetFileCount = count
  1177. END FUNCTION
  1178.  
  1179. SUB MonoDisplay
  1180.     DisplayType = FALSE
  1181.     MouseHide
  1182.     SetupMenu
  1183.     MenuSetState 2, 1, 1
  1184.     MenuSetState 2, 2, 2
  1185.     SetupDesktop
  1186.     MenuShow
  1187.     MouseShow
  1188. END SUB
  1189.  
  1190. DEFSNG A-Z
  1191. SUB SetupDesktop STATIC
  1192.  
  1193.     MouseHide
  1194.  
  1195.     WIDTH , 25
  1196.  
  1197.     IF DisplayType THEN
  1198.         COLOR 15, 1      'Color
  1199.     ELSE
  1200.         COLOR 15, 0      'Monochrome
  1201.     END IF
  1202.     CLS
  1203.  
  1204.     FOR a = 2 TO 80 STEP 4
  1205.         FOR B = 2 TO 25 STEP 2
  1206.             LOCATE B, a
  1207.             PRINT CHR$(250);
  1208.         NEXT B
  1209.     NEXT a
  1210.  
  1211.     MouseShow
  1212. END SUB
  1213.  
  1214. DEFINT A-Z
  1215. SUB SetupMenu
  1216.  
  1217.     MenuSet 1, 0, 1, "Demos", 1
  1218.     MenuSet 1, 1, 1, "Alert Window         F1", 1
  1219.     MenuSet 1, 2, 1, "Dialog Box (Simple)  F2", 13
  1220.     MenuSet 1, 3, 1, "Dialog Box (Complex) F3", 13
  1221.     MenuSet 1, 4, 1, "List Boxes           F4", 1
  1222.     MenuSet 1, 5, 1, "List Box w/File List F5", 12
  1223.     MenuSet 1, 6, 1, "Scroll Bars          F6", 8
  1224.     MenuSet 1, 7, 1, "Windows - Multiple   F7", 11
  1225.     MenuSet 1, 8, 1, "Window - Resizable   F8", 10
  1226.     MenuSet 1, 9, 1, "-", 1
  1227.     MenuSet 1, 10, 1, "Exit             Ctrl-X", 2
  1228.                           
  1229.     MenuSet 2, 0, 1, "Options", 1
  1230.     MenuSet 2, 1, 1, "Color", 1
  1231.     MenuSet 2, 2, 1, "Monochrome", 1
  1232.     
  1233.  
  1234.     MenuSet 3, 0, 1, "Help", 1
  1235.     MenuSet 3, 1, 1, "About This Demo", 12
  1236.     MenuSet 3, 2, 1, "About The User Interface", 11
  1237.     MenuSet 3, 3, 1, "About the Windows", 11
  1238.     MenuSet 3, 4, 1, "Using the Mouse", 11
  1239.     MenuSet 3, 5, 1, "Using Access Keys", 7
  1240.     MenuSet 3, 6, 1, "Using Quick Keys", 7
  1241.  
  1242.     ShortCutKeySet 1, 1, CHR$(0) + CHR$(59) ' F1
  1243.     ShortCutKeySet 1, 2, CHR$(0) + CHR$(60) ' F2
  1244.     ShortCutKeySet 1, 3, CHR$(0) + CHR$(61) ' F3
  1245.     ShortCutKeySet 1, 4, CHR$(0) + CHR$(62) ' F4
  1246.     ShortCutKeySet 1, 5, CHR$(0) + CHR$(63) ' F5
  1247.     ShortCutKeySet 1, 6, CHR$(0) + CHR$(64) ' F6
  1248.     ShortCutKeySet 1, 7, CHR$(0) + CHR$(65) ' F7
  1249.     ShortCutKeySet 1, 8, CHR$(0) + CHR$(66) ' F8
  1250.  
  1251.     ShortCutKeySet 1, 10, CHR$(24)          ' Ctrl-X
  1252.  
  1253.     IF NOT DisplayType THEN
  1254.         MenuColor 0, 7, 15, 8, 7, 0, 15   'Best for monochrome and colors
  1255.     ELSE
  1256.         MenuColor 0, 7, 4, 8, 15, 0, 12   'Best for color
  1257.     END IF
  1258.  
  1259.     MenuPreProcess
  1260.  
  1261. END SUB
  1262.