13.07.2015 Views

Turbo Basic

Turbo Basic

Turbo Basic

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

See AlsoExampleAs an example, suppose we want to trap "shift-escape"; that is,we want a certain subroutine to get control whenever the Esc key ispressed along with either Shift key. First, you must build the shiftstatusmask. You want both Shift keys to be recognized, so you mustadd the masks for each: 01H + 02H = 03H. Next you can consultthe scan code table in Appendix F and discover that the Esc key hasscan code 1. The following statement tells <strong>Turbo</strong> <strong>Basic</strong> about yourplan:KEY 15,CHR$(&03) + CHR$(I)You must use key value 15 because the first 14 are predefined torepresent the function and cursor control keys. Next you define atrap subroutine to be called whenever Shift-Esc is pressed:ON KEY(15) GOSUB ShiftEscapewhere ShiftEscape is a label at the start of the trap subroutine.Finally you turn on trapping for key 15 with the KEY(n) statement:KEY(15) ONKEY(n)ON KEY, This program shows the KEY ON/OFF and, KEY N string expressions, turn off function key displayKEY OFF, assign string expressions to the function keysFOR N% = 1 TO 10READ A$KEY N%, A$ + CHR$(13)NEXT N%KEY LIST 'Display function key definitions, turn on function key displayKEY ON, wait for user to press a keyWHILE NOT INSTATWEND, data statements used by READDATA Help, Enter, Edit, Change, Report, Print, SetupDATA DOS, Copy, QuitEND, end the program238<strong>Turbo</strong> <strong>Basic</strong> Owner's Handbook

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!