home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / Basic_Plus_Examples / ONEVENT < prev    next >
Encoding:
Text File  |  2001-03-02  |  1.7 KB  |  38 lines

  1. 10    ! ************************************************
  2. 20    ! Example: Using ON EVENT
  3. 30    !
  4. 40    ! This program shows one way ON EVENT can be
  5. 50    ! used for error handling.
  6. 60    !
  7. 70    ! ***********************************************
  8. 80    !
  9. 90       ON SIGNAL 15 CALL Sig15_handler
  10. 100       ON ERROR CALL Error_handler
  11. 110       A=0/0
  12. 120       DIALOG "INFORMATION","After divide by zero error"
  13. 130       END
  14. 140   !
  15. 150       SUB Sig15_handler
  16. 160           ASSIGN @Printer TO WIDGET "PRINTER"
  17. 170           CONTROL @Printer;SET ("X":0,"Y":0,"TITLE":"Event Record")
  18. 180           CONTROL @Printer;SET ("TEXT":"ERROR: "&ERRM$)
  19. 190           CONTROL @Printer;SET ("APPEND TEXT":"ON SIGNAL 15 System Priority: "&SYSTEM$("SYSTEM PRIORITY"))
  20. 200           STATUS @Printer;RETURN ("WIDTH":X,"HEIGHT":Y)
  21. 210     !
  22. 220           ASSIGN @Button TO WIDGET "PUSHBUTTON";SET ("VISIBLE":0,"RESIZABLE":0,"TITLE":"","LABEL":"PUSH ME")
  23. 230           STATUS @Button;RETURN ("WIDTH":W,"HEIGHT":H)
  24. 240           CONTROL @Button;SET ("X":(X-W)/2,"Y":(Y-H)/2,"VISIBLE":1)
  25. 250           ON EVENT @Button,"ACTIVATED",15 GOTO Okd
  26. 260           LOOP
  27. 270               WAIT FOR EVENT
  28. 280               CONTROL @Printer;SET ("APPEND TEXT":"WAIT FOR EVENT terminated and branch taken (this statement never executed).")
  29. 290           END LOOP
  30. 300  Okd: CONTROL @Printer;SET ("APPEND TEXT":"Branch taken.")
  31. 310           WAIT 1
  32. 320       SUBEND
  33. 330       SUB Error_handler
  34. 340           DIALOG "INFORMATION","Now in error handler. System Priority: "&SYSTEM$("SYSTEM PRIORITY")&CHR$(10)&"asserting signal 15"
  35. 350           SIGNAL 15
  36. 360           ERROR SUBEXIT
  37. 370       SUBEND
  38.