User Tools

Site Tools


copy_20key_20functionality_20with_20get_20and_20inkey

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

copy_20key_20functionality_20with_20get_20and_20inkey [2018/03/31 13:19]
127.0.0.1 external edit
copy_20key_20functionality_20with_20get_20and_20inkey [2018/04/16 10:46] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Copy Key functionality with GET and INKEY===== =====Copy Key functionality with GET and INKEY=====
  
-//by Richard Russell, April 2008//\\ \\  BBC BASIC for Windows emulates the [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin2.html#​copyediting|Copy Key]] functionality provided on the BBC Microcomputer and other Acorn machines, but only at the Immediate Mode prompt or when user input is being requested using the INPUT statement; Copy Key editing is //not// available when the keyboard is read using GET or INKEY. The main reason for this limitation is that, in the absence of a dedicated Copy key, the Tab key is used instead to initiate the Copy operation. When GET or INKEY is used, the Tab key returns its normal ASCII value (9).\\ \\  Occasionally,​ especially when porting a program from an Acorn platform, it might be convenient for Copy Key editing to be available when using GET or INKEY. The code below provides this capability, by means of the user-defined function **FNinkeycopy**. This emulates the INKEY function (with a zero or positive parameter) but with the Tab key acting as the Copy key:\\ \\ +//by Richard Russell, April 2008//\\ \\  BBC BASIC for Windows emulates the [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwin2.html#​copyediting|Copy Key]] functionality provided on the BBC Microcomputer and other Acorn machines, but only at the Immediate Mode prompt or when user input is being requested using the INPUT statement; Copy Key editing is //not// available when the keyboard is read using GET or INKEY. The main reason for this limitation is that, in the absence of a dedicated Copy key, the Tab key is used instead to initiate the Copy operation. When GET or INKEY is used, the Tab key returns its normal ASCII value (9).\\ \\  Occasionally,​ especially when porting a program from an Acorn platform, it might be convenient for Copy Key editing to be available when using GET or INKEY. The code below provides this capability, by means of the user-defined function **FNinkeycopy**. This emulates the INKEY function (with a zero or positive parameter) but with the Tab key acting as the Copy key: 
 + 
 +<code bb4w> ​
         DEF FNinkeycopy(T%)         DEF FNinkeycopy(T%)
         LOCAL K%         LOCAL K%
Line 45: Line 47:
         SYS "​InvalidateRect",​ @hwnd%, rc{}, 0         SYS "​InvalidateRect",​ @hwnd%, rc{}, 0
         ENDPROC         ENDPROC
-Note that, just as in the case of Immediate Mode and the INPUT statement, Copy editing must be initiated by first pressing Tab. This differs slightly from the way it works on machines having a dedicated Copy key. Copy editing mode is terminated when **Enter** is pressed, or explicitly by pressing **Shift+Tab**.\\ \\  To emulate **GET**, with Copy Key editing, you can use the following function:\\ \\ +</​code>​ 
 + 
 +Note that, just as in the case of Immediate Mode and the INPUT statement, Copy editing must be initiated by first pressing Tab. This differs slightly from the way it works on machines having a dedicated Copy key. Copy editing mode is terminated when **Enter** is pressed, or explicitly by pressing **Shift+Tab**.\\ \\  To emulate **GET**, with Copy Key editing, you can use the following function: 
 + 
 +<code bb4w>
         DEF FNgetcopy         DEF FNgetcopy
         LOCAL K%         LOCAL K%
Line 52: Line 58:
         UNTIL K%<>​-1         UNTIL K%<>​-1
         = K%         = K%
 +</​code>​
copy_20key_20functionality_20with_20get_20and_20inkey.txt · Last modified: 2018/04/16 10:46 by richardrussell