17 February 2022, 20:58 | #1 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 201
|
Porting to AmigaBASIC to ACE questions
I'm porting some old AmigaBASIC code to ACE. Many things work with only small changes. But I don't found out how to get it when a cursor key is pressed. In AmigaBASIC this is done with INPUT$, followed by ASC(). In ACE this only works for printable keys like 'A'.
Code example where only the 'A' is recognized: Code:
'... Open window etc 'Non-busy wait until a key is pressed WHILE c$="" SLEEP c$=INKEY$ WEND c = ASC(c$) 'Get ASCII value from key IF c=65 THEN print "A" 'This works END IF IF c=28 THEN print "Cursor up" END IF IF c=29 THEN print "Cursor down" END IF IF c=30 THEN print "Cursor left" END IF IF c=31 THEN print "Cursor right" END IF '... Close window and end |
18 February 2022, 01:56 | #2 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,223
|
I think the problem is the raw mode console device filtering out control characters it can process itself.
That's just a guess though. |
18 February 2022, 02:09 | #3 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 729
|
After (minimal) testing, it seems cursor keys don't trigger INKEY$ even in own window (in shell console indeed is in cooked mode), so I don't think you can read the cursor keys with ace.
testing program follows Code:
defint a-z screen 1,320,200,3,1 palette 0,0,0,0 palette 1,0,0,1 palette 2,0,1,0 palette 3,0,1,1 palette 4,1,0,0 palette 5,1,0,1 palette 6,1,1,0 palette 7,1,1,1 window 1,"Hello World! <press 'q' key to quit>",(0,0)-(320,200),32,1 c$="" while c$<>"q" c$="" while c$="" sleep c$=inkey$ wend x=rnd*80 y=rnd*25 repeat f=rnd*7+1 b=rnd*8 until f <> b color f,b locate y,x print asc(c$); wend window close 1 screen close 1 |
18 February 2022, 09:45 | #4 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 201
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmigaBASIC, ACE compiler and WINDOW | PDrill | support.Apps | 2 | 05 November 2020 06:20 |
AmigaBASIC | gurth | support.Apps | 4 | 19 June 2020 23:05 |
AmigaBASIC Compilers | Leandro Jardim | request.Apps | 4 | 22 May 2013 22:59 |
MOUSE(0) and AmigaBASIC ... | MacTO | Coders. General | 3 | 01 September 2006 16:19 |
AmigaBASIC unprotector | Minuous | request.Apps | 1 | 01 June 2005 23:28 |
|
|