English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Language (https://eab.abime.net/forumdisplay.php?f=114)
-   -   Porting to AmigaBASIC to ACE questions (https://eab.abime.net/showthread.php?t=109849)

thyslo 17 February 2022 20:58

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

Has anybody an idea how to get the cursor keys?

Samurai_Crow 18 February 2022 01:56

I think the problem is the raw mode console device filtering out control characters it can process itself.

That's just a guess though.

alkis 18 February 2022 02:09

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


thyslo 18 February 2022 09:45

Quote:

Originally Posted by alkis (Post 1532700)
so I don't think you can read the cursor keys with ace.

I was already afraid of that. Thank you for trying it out.


All times are GMT +2. The time now is 17:26.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04734 seconds with 11 queries