home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / interpre / liberty / os2 / checkbox.bas < prev    next >
BASIC Source File  |  1994-03-06  |  1KB  |  61 lines

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