Simulate input/Keyboard: Difference between revisions
Content added Content deleted
(Added Wren) |
(→{{header|Commodore BASIC}}: Add implementation.) |
||
Line 40: | Line 40: | ||
$name = InputBox("Name","Your name please ?",$name) |
$name = InputBox("Name","Your name please ?",$name) |
||
MsgBox(0,"Name","Your name is: "&$name)</lang> |
MsgBox(0,"Name","Your name is: "&$name)</lang> |
||
=={{header|BASIC}}== |
|||
==={{header|Commodore BASIC}}=== |
|||
Most of the logic here is dedicated to detecting which Commodore model the program is being run on, in order to use the correct addresses for the keyboard input buffer. |
|||
<lang basic>100 : REM SIMULATE KEYBORD INPUT |
|||
110 GOSUB 170:REM DETERMINE MODEL/LOCATIONS |
|||
120 PRINT CHR$(147);"NAME? MARK";CHR$(19); |
|||
130 POKE KB,13:POKE NC,1:REM PUT A RETURN IN BUFFER |
|||
140 INPUT "NAME"; N$ |
|||
150 PRINT "HELLO, "N$"!" |
|||
160 END |
|||
170 : REM DETECT MODEL |
|||
180 V=40:GOSUB 260:IF B=58 THEN NC=158:KB=624:RETURN:REM PET |
|||
190 V=43:GOSUB 260:IF B<>58 THEN 240 |
|||
200 IF A=1025 OR A=2049 OR A=4609 THEN NC=198:KB=631:RETURN:REM VIC-20 OR C64 |
|||
210 IF A<>4097 THEN 240 |
|||
220 IF PEEK(65305)=238 THEN NC=239:KB=1319:RETURN:REM C-16 OR PLUS/4 |
|||
230 IF PEEK(36879)=27 THEN NC=198:KB=631:RETURN:REM UNEXPANDED VIC-20 |
|||
240 V=45:GOSUB 260:IF B=58 THEN NC=208:KB=842:RETURN:REM C-128 |
|||
250 PRINT "UNKNOWN MODEL!":END |
|||
260 A=PEEK(V)+256*PEEK(V+1):B=PEEK(A+4):RETURN</lang> |
|||
{{Out}} |
|||
<pre>NAME? MARK |
|||
HELLO, MARK! |
|||
READY.</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |