home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / compiler / sample4.bas < prev    next >
BASIC Source File  |  1993-06-21  |  2KB  |  112 lines

  1.  
  2. rem
  3. rem Now let's use one of BasicBasic's more advanced features.
  4. rem
  5. rem If you don't have a mouse use F10 to access the menu.
  6. rem
  7. rem This program is a simple example of using menu's.
  8. rem
  9. rem In this case we display the current time and the user can select
  10. rem the color of the background using a menu.  The current color
  11. rem will be 'grayed' so it cannot be selected.
  12. rem
  13.  
  14.  
  15.   y=mouseon
  16.  
  17.   rem
  18.   rem define my menu bar at top of screen
  19.   rem
  20.   mainmenu "&Color","","","","",""
  21.  
  22.   rem
  23.   rem define menu items
  24.   rem
  25.   rem  the '&' symbol tells windows what keyboard shortcut will select this
  26.   addsubmenu 1,"&Black",1059
  27.   addsubmenu 1,"&Red",1060
  28.   addsubmenu 1,"&Blue",1061
  29.   addsubmenu 1,"",0
  30.   addsubmenu 1,"&Quit",1062
  31.  
  32.   bcolor=1
  33.   color 7,bcolor
  34.   cls
  35.  
  36.   rem
  37.   rem gray menu option for current color
  38.   rem
  39.   menuitemgray 1061
  40.  
  41. 100
  42.  
  43.   rem
  44.   rem get and display time
  45.   rem
  46.   t$=time$
  47.   if t$<>oldt$ then
  48.     oldt$=t$
  49.     locate 12,35,0
  50.     print t$;
  51.   end if
  52.   a$=inkey$
  53.   if a$="" then goto 100
  54.  
  55.  
  56.   rem
  57.   rem Come here if key pressed.  If menu item is selected it will look like
  58.   rem a key pressed!
  59.   rem
  60.  
  61.   if len(a$)=1 then goto 100
  62.  
  63.   if right$(a$,1)=chr$(59) then
  64.     rem
  65.     rem change to black
  66.     rem
  67.     menuitemon 1060
  68.     menuitemon 1061
  69.     menuitemgray 1059
  70.     bcolor=0
  71.     color 7,bcolor
  72.     cls
  73.     oldt$=""
  74.  
  75.   elseif right$(a$,1)=chr$(60) then
  76.     rem
  77.     rem change to red
  78.     rem
  79.     menuitemon 1059
  80.     menuitemon 1061
  81.     menuitemgray 1060
  82.     bcolor=4
  83.     color 7,bcolor
  84.     cls
  85.     oldt$=""
  86.  
  87.   elseif right$(a$,1)=chr$(61) then
  88.     rem
  89.     rem change to white
  90.     rem
  91.     menuitemon 1059
  92.     menuitemon 1060
  93.     menuitemgray 1061
  94.     bcolor=1
  95.     color 7,bcolor
  96.     cls
  97.     oldt$=""
  98.  
  99.   elseif right$(a$,1)=chr$(62) then
  100.  
  101.     color 15,0
  102.     cls
  103.     stop
  104.  
  105.   end if
  106.  
  107.   goto 100
  108.  
  109.  
  110.  
  111.  
  112.