English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language

 
 
Thread Tools
Old 17 February 2022, 20:58   #1
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
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?
thyslo is offline  
Old 18 February 2022, 01:56   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
I think the problem is the raw mode console device filtering out control characters it can process itself.

That's just a guess though.
Samurai_Crow is offline  
Old 18 February 2022, 02:09   #3
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
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
alkis is offline  
Old 18 February 2022, 09:45   #4
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 189
Quote:
Originally Posted by alkis View Post
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.
thyslo is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:57.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.18074 seconds with 13 queries