do i have to use the inkey$ each time?

Basic and Machine Language

Moderator: Moderators

Post Reply
20questions
Vic 20 Hobbyist
Posts: 114
Joined: Sun Mar 10, 2019 7:39 pm
Location: lodi california
Occupation: student

do i have to use the inkey$ each time?

Post by 20questions »

how would i use inkey$ and get a$ together? do i have to use it again and again for each decision. can i make a macro in cbm basic to speed up the process?

this is the line i am trying to fix

8 let a$=inkey$:get a$
:if a$="t" then goto 1
00

the problem is that it never works, it just goes to the end of the game. ideas?
working on version 2 of the thing, the first one was so messed up i had to bin it. :oops:
Bedroom coder=rock star
modern coder= pop star
i'd rather be a rock star than a pop start 8)
User avatar
srowe
Vic 20 Scientist
Posts: 1356
Joined: Mon Jun 16, 2014 3:19 pm

Re: do i have to use the inkey$ each time?

Post by srowe »

inkey$ doesn't exist in CBM BASIC. It serves a similar purpose to get in other dialects.

In your example the

Code: Select all

let a$=inkey$
part is essentially a no-op as it just assigns the contents of the variable in$ to a$ (variables in CBM BASIC are at most two characters).

If you want to wait for a single key you want

Code: Select all

8 get a$:if a$=""goto 8
20questions
Vic 20 Hobbyist
Posts: 114
Joined: Sun Mar 10, 2019 7:39 pm
Location: lodi california
Occupation: student

Re: do i have to use the inkey$ each time?

Post by 20questions »

thank you very much :D
Bedroom coder=rock star
modern coder= pop star
i'd rather be a rock star than a pop start 8)
User avatar
Mike
Herr VC
Posts: 4901
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: do i have to use the inkey$ each time?

Post by Mike »

Please refer to the VIC-20 User's Manual for these kind of questions.

Especially, handling keyboard input with GET is explained with example programs on pages 89 to 92, and you find further information on GET on page 122.
Post Reply