home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lb091.zip / CHECKBOX.BAS < prev    next >
BASIC Source File  |  1995-10-02  |  1KB  |  62 lines

  1.  
  2.     ' CHECKBOX.BAS
  3.     ' This code demonstrates how to use checkboxes in your
  4.     ' Liberty BASIC programs
  5.  
  6.     ' no main text mode window, please
  7.     nomainwin
  8.  
  9.     ' list all the controls for our dialog box window
  10.     button #1, " &Ok ", [quit], UL, 120, 90
  11.     checkbox #1.cb, "I am a checkbox", [set], [reset], 10, 10, 130, 20
  12.     button #1, " Set ", [set], UL, 10, 50
  13.     button #1, " Reset ", [reset], UL, 50, 50
  14.     textbox #1.text, 10, 90, 100, 24
  15.  
  16.     ' set the size for our window
  17.     WindowWidth = 180
  18.     WindowHeight = 160
  19.  
  20.     ' open the window
  21.     open "Checkbox test" for dialog as #1
  22.  
  23.     ' intercept the close message and goto [quit]
  24.     print #1, "trapclose [quit]"
  25.  
  26.  
  27. [inputLoop]    ' this is where we sit idle, waiting for the user to click
  28.  
  29.     input r$ 
  30.     stop
  31.  
  32. [set]    ' the user clicked on the Set button, set the checkbox
  33.  
  34.     print #1.cb, "set"
  35.     goto [readCb]
  36.  
  37.  
  38. [reset]    ' the user clicked on the Reset button, clear the checkbox
  39.     print #1.cb, "reset"
  40.     goto [readCb]
  41.  
  42.  
  43. [readCb]    ' set the contents of the textbox
  44.  
  45.     ' query the checkbox for its state
  46.     print #1.cb, "value?"
  47.     input #1.cb, t$
  48.  
  49.     ' set the contents of our textbox
  50.     print #1.text, "I am "; t$
  51.  
  52.     goto [inputLoop]
  53.  
  54.  
  55. [quit]    ' check to see if we should quit
  56.  
  57.     confirm "Do you want to quit?"; answer$
  58.     if answer$ <> "yes" then [inputLoop]
  59.  
  60.     close #1
  61.     end
  62.