What does A$ get set to?Grumpy Mike wrote:RISC OS 12a
Some of my code uses
A$ = GET$
to pause until a user hits a key.
No it is Acorn BasicVbut is this PowerBasic?
Well using $ means that any key can be pressed without generating an error. I have always used it for things like "Press any key to continue"Is there a reason for using
It gets set to the key you pressed.What does A$ get set to?
That's essentially what I use GET for, only it returns the ASCII code of the key, rather than a string. I've forgotten what happens if I press an F key - yet another thing to try when it's raining.Grumpy Mike wrote:Well using $ means that any key can be pressed without generating an error. I have always used it for things like "Press any key to continue"
Thanks for the reply.neilf wrote:Are you sure your program isn't messing with the keyboard auto repeat rates? *FX11 and *FX12 are the usual commands I think. The rate is often altered in a program using keys for continuous actions - perhaps in a game - or to cut out the initial pause before a key is repeated.
Code: Select all
REM PRINT FOR i%=0 TO 100 A%=GET PRINT i%,A% NEXT PRINT "wait ..." t%=TIME:REPEAT:UNTIL TIME>t%+100 FOR i%=0 TO 1000 A$=GET$ PRINT i%," ",A$ NEXT PRINT "wait ..." t%=TIME:REPEAT:UNTIL TIME>t%+500 END
True but I am not holding down the key and even a buffer flush before the read produced the same results. See reply #1svrsig wrote:it is likely that the keyboard buffer will be filled with repeat presses. Next time your programme says 'press any key' the GET$ statement simply gets the next key press from the buffer and therefore appears to continue immediately without waiting.
Thanks very much for that, it allowed me to solve the problem. Your code did not work on my machine so I investigated a bit.Burngate wrote:Okay, it's got me so irritated, .............
I wrote it on VirtualRPC - both bits work perfectly.
There is no difference in the keys that can be detected. GET$ is equivalent to CHR$(GET) and GET is equivalent to ASC(GET$). A% is more efficient because it is a resident integer variable, whereas A$ is allocating completely unnecessary string storage.Burngate wrote:Is there a reason for using
Code: Select all
Yes but on the almost infinite memory you have on the Raspberry Pi as compared to a RISC PC, I am willing to live with that.Two bytes less code and no run time storage at all.
Hardware 'bugs' are always elusive. Despite using the manufacturer's recommended clock circuit for the Z80, the shape of the clock pulse on an unmodified Nascom 2 caused a small number of machine code instructions to go predictably wrong. This was called the 'string bug' as it caused a string error in BASIC. It was solved by overloading the clock circuit with a capacitor (I think) but must have been a swine to fault find.What it turned out to be was the power lead. It was dropping just a tad too much voltage for the keyboard.