From: Sam on
I'm looking for the basic command (s) how a key be used as a "switch".
So once pressing is on and pressing again is off and so on. I can't
find it. Who knows ?? Thanx, SAM
From: bogax on
On Jan 17, 5:22 pm, Sam <siemappel...(a)quicknet.nl> wrote:
> I'm looking for the basic command (s) how a key be used as a "switch".
> So once pressing is on and pressing again is off and so on. I can't
> find it. Who knows ?? Thanx, SAM

(from the Commodore 64 Programmers Reference Guide)

GET

TYPE: Statement
FORMAT: GET <variable list>

Action: This statement reads each key typed by the user. As the
user is
typing, the characters are stored in the Commodore 64's keyboard
buffer.
Up to 10 characters are stored here, and any keys struck after the
10th
are lost. Reading one of the characters with the GET statement makes
room
for another character.
If the GET statement specifies numeric data, and the user types a
key
other than a number, the message ?SYNTAX ERROR appears. To be safe,
read
the keys as strings and convert them to numbers later.

The GET statement can be used to avoid some of the limitations of
the
INPUT statement. For more on this, see the section on Using the GET
Statement in the Programming Techniques section.

EXAMPLES of GET Statement:

10 GET A$: IF A$ ="" THEN 10: REM LOOPS IN 10 UNTIL ANY KEY HIT
20 GET A$, B$, C$, D$, E$: REM READS 5 KEYS
30 GET A, A$
From: Vanessa Ezekowitz on
On Sun, 17 Jan 2010 16:22:01 -0800 (PST)
Sam <siemappelman(a)quicknet.nl> wrote:

> I'm looking for the basic command (s) how a key be used as a "switch".
> So once pressing is on and pressing again is off and so on. I can't
> find it. Who knows ?? Thanx, SAM

A simple bit of code to use the F1 and F3 keys as toggle switches might look
like this:

10 GET A$: IF A$="" THEN 10
20 IF A$=CHR$(133) THEN X=1-X
30 IF A$=CHR$(134) THEN Y=1-Y
40 PRINT X,Y
50 GOTO 10

Of course, what you do with those toggle variables is entirely up to you.

--
"There are some things in life worth obsessing over. Most
things aren't, and when you learn that, life improves."
http://starbase.globalpc.net/~ezekowitz
Vanessa E. <vanDEesLEsaTEezTHekISowitz(a)gmail.com>
(Delete the obvious to email me)


--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Sam on
Just what I was looking for..

Thank you very much Vanessa !

Regards, SAM (www.siemappelman.nl)

From: Adric22 on
> A simple bit of code to use the F1 and F3 keys as toggle switches might look
> like this:
>
> 10 GET A$: IF A$="" THEN 10
> 20 IF A$=CHR$(133) THEN X=1-X
> 30 IF A$=CHR$(134) THEN Y=1-Y
> 40 PRINT X,Y
> 50 GOTO 10

You know, I wasn't looking for or needing any code like that, I was
just casually reading through. But lines 20 and 30 are brilliant! I
would have never thought of such a simple mechanism. I can't tell you
how many times I could have used something like that in my code but
instead I always wind up writing two conditional statements, something
to the effect of:

IF X=0 THEN X=1
IF X=1 THEN X=0

Anyway, your method is much more efficient and I'm pretty sure the
same concept would work in assembly language as well using the SBC
command.