Jump to content
IGNORED

problem with Atari basic


Ranger03

Recommended Posts

If then is not working correctly, usually, a simple if then loop works perfectly but here, then is highlighted.

 

example: dim a$(5):if a$="a" then goto 20

 

the other issue is the lack of an inkey$ command, what can other commands can i use (my memory is not that great so poking 24/7 is out of the question)

Link to comment
Share on other sites

As for inkey$ - A quick google search

 

As mentioned earlier, the version of BASIC for Atari's eight-bit computers has no built-in statement designed specifically to retrieve a single keypress. However, you can achieve the same effect by first opening a channel to the keyboard device with the statement OPEN #1, 4, 0, "K:", then using GET#1 to retrieve character values. (Any unused file number in the range 17 can be substituted for the 1 in these statements). The main difference between the Atari's GET#, and the INPUT$ and GET commands described above, is that GET# returns character code values rather than string characters, so GET# must always be followed by a numeric variable. If characters are desired, the CHR$ function can be used. Also, note that GET# waits for a key to be pressed.

 

To modify the first example program segment in this article for eight-bit Ataris, you must first add lines to open the channel for input and set up the testing variable:

 

100 OPEN #1, 4, 0, "K"

110 DIM K$(1)

This needs to be done only once in the program, but it must be done before the first GET# command. Then replace line 210 with:

 

210 GET #1, K : K$ = CHR$(K)

You may find it easier to simply check for character code values rather than characters. Refer to your BASIC manual for a complete list of Atari ASCII codes. For example, you could test for a RETURN keypress with

 

300 PRINT "PRESS RETURN TO CONTINUE."

310 GET#1, R:IF R< >155 THEN 310

Link to comment
Share on other sites

As for inkey$ - A quick google search

 

As mentioned earlier, the version of BASIC for Atari's eight-bit computers has no built-in statement designed specifically to retrieve a single keypress. However, you can achieve the same effect by first opening a channel to the keyboard device with the statement OPEN #1, 4, 0, "K:", then using GET#1 to retrieve character values. (Any unused file number in the range 17 can be substituted for the 1 in these statements). The main difference between the Atari's GET#, and the INPUT$ and GET commands described above, is that GET# returns character code values rather than string characters, so GET# must always be followed by a numeric variable. If characters are desired, the CHR$ function can be used. Also, note that GET# waits for a key to be pressed.

 

To modify the first example program segment in this article for eight-bit Ataris, you must first add lines to open the channel for input and set up the testing variable:

 

100 OPEN #1, 4, 0, "K"

110 DIM K$(1)

This needs to be done only once in the program, but it must be done before the first GET# command. Then replace line 210 with:

 

210 GET #1, K : K$ = CHR$(K)

You may find it easier to simply check for character code values rather than characters. Refer to your BASIC manual for a complete list of Atari ASCII codes. For example, you could test for a RETURN keypress with

 

300 PRINT "PRESS RETURN TO CONTINUE."

310 GET#1, R:IF R< >155 THEN 310

line 100 needs a colon in the quotes OPEN #1,4,0,"K:"

 

devices for OPEN are:

C: recorder

D(n): disk drive

E: screen editor

K: key press

P: printer

R(n): serial port

S: screen (how?) you can only output to the screen

 

I think E: and K: do the same thing.

no E: can only 8, output,

12 keyboard input & screen output

13 screen input & output (from Poole and McNiff 'Your Atari Computer"

 

You had it in the paragraph correct.

I think, don't use "E:"

Edited by russg
  • Like 1
Link to comment
Share on other sites

If then is not working correctly, usually, a simple if then loop works perfectly but here, then is highlighted.

 

example: dim a$(5):if a$="a" then goto 20

 

the other issue is the lack of an inkey$ command, what can other commands can i use (my memory is not that great so poking 24/7 is out of the question)

You need a line number. You cannot go to a line number in immediate mode. I tested on my 130XE and it works fine in a program.

  • Like 2
Link to comment
Share on other sites

If you just want to read a keypress, do poke 764,255, c=peek(764): if c=(desired key code) then goto whatever.:poke 764,255 to reset it again

 

easiest way. Poke it with 255 first to clear it, read it, then poke it back to $FF to clear it again after you're done with it.

so if i was to make a text adventure, i would need to poke the same address everytime i wanted input?

Link to comment
Share on other sites

so if i was to make a text adventure, i would need to poke the same address everytime i wanted input?

 

If you wanted to input lines of text for a text adventure, followed by a carriage return, you can skip the OPEN E:/K: etc, and just simply use INPUT command, DIM'd appropriately of course (intentionally small here for demonstration...)

10 DIM INPUT$(10)
20 INPUT INPUT$
30 PRINT INPUT$

RUN
?THE QUICK BROWN FOX
THE QUICK

Another neat trick to ditch the "?" at each input is to use IOCB #16, which BASIC treats as #0, described here: http://www.page6.org/archive/issue_32/page_12.htm

10 DIM INPUT$(10)
20 INPUT #16,INPUT$
30 PRINT INPUT$

RUN
THIS IS A TEST
THIS IS A

... and make your own prompt:

10 DIM INPUT$(10)
20 ? "COMMAND-->";:INPUT #16,INPUT$
30 PRINT INPUT$

READY
RUN
COMMAND-->THE QUICK BROWN FOX
THE QUICK
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...