home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / Basic / QWINDO.ZIP / GETYESNO.BAS < prev    next >
Encoding:
BASIC Source File  |  1990-01-01  |  2.1 KB  |  58 lines

  1. '============================================================================
  2. '  GETYESNO.BAS - A sample program for QuickWindows Standard
  3. '  YES/NO Message Box Prompt
  4. '============================================================================
  5.  
  6. REM $DYNAMIC
  7. DEFINT A-Z              'Make all variables integers by default.
  8. DIM SHARED w(4000)      'Dimension an integer array for our window.
  9. CALL QWINIT(4)          'Need to call this command before using any QW commands.
  10. CLS                     'Clear the screen.
  11.  
  12. Msg$ = "Sample message.  Continue?"
  13. GOSUB GetYesNo
  14. LOCATE 21, 1
  15. IF (result = 0) AND (focus = 0) THEN
  16.     PRINT "You've exited without making a selection."
  17. ELSE
  18.     PRINT "You Selected: "; result
  19. END IF
  20. END
  21. '---------------------------------------------------------------------------
  22. ' GetYesNo - Display a message prompt in Msg$ and prompt user for Yes or No.
  23. ' Size of window is determined by length of Msg$.
  24. ' Window slot 1 is used.
  25. '
  26. GetYesNo:
  27. strlen = LEN(Msg$)              'Need length of string to print.
  28. wx1 = INT((80 - strlen) / 2)    'Center the window on the screen.
  29. wx2 = wx1 + strlen + 5          'Setup right border
  30. wy1 = 8                         'Upper edge of window.
  31. wy2 = wy1 + 6                   'Lower edge.
  32. wstyle = 1                      'Window border style = Single line.
  33. wincolor = &H74                 'Color = Red on White.
  34. title$ = ""                     'No title in window.
  35. id = 1
  36. CALL WOPEN(wx1, wy1, wx2, wy2, wstyle, wincolor, title$, w(), id)
  37. CALL WCLS(id)                   'Clear the window.
  38. CALL WLOCATE(id, 2, 0)          '& Locate the cursor.
  39. CALL WPRINT(id, Msg$)           '& Print our message.
  40. strlen2 = strlen / 2
  41. bstyle = 2
  42. bcolor = &H79
  43. CALL WBUTTONSET(id, 1, 0, bsytle, bcolor, 2, &H71, strlen2 - 9, 2, " No ")
  44. CALL WBUTTONSET(id, 2, 0, bstyle, bcolor, 2, &H71, strlen2 + 5, 2, " Yes ")
  45. focus = 1
  46. DO
  47.     CALL WBUTTONGET(focus, 1, 2, result)
  48.     IF (focus = 0) AND (result = 0) THEN EXIT DO 'Trap for Escape key.
  49.     IF focus < 1 THEN
  50.     focus = 2
  51.     ELSEIF focus > 2 THEN
  52.     focus = 1
  53.     END IF
  54. LOOP WHILE result = 0
  55. CALL WCLOSE(id)
  56. RETURN
  57.  
  58.