Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Single key entry

Author
Message
Namdekan
20
Years of Service
User Offline
Joined: 25th Feb 2005
Location:
Posted: 26th Feb 2005 06:45
Hello all,

Just about everything else I've figured out on my own, or through the tutorials. However, I'm looking for one function that I can't figure out. I would like to prod the user for an input, but I want it to be a single key, and I want it to only be specific characters. For instance, a yes/no input. How can I ask the user 'Do you blah blah blah? (y/n)' Then as soon as they hit the y or the n key, the program continues. Hit anything else, and it continues to wait. Also, is there something I would have to alter to be able to accept upper and lower case, ie: Y or y for yes, and N or n for no? Thanks for any help!

Namdekan
MSon
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Earth, (I Think).
Posted: 26th Feb 2005 08:22 Edited at: 26th Feb 2005 08:23
Do you Mean Like This?

Namdekan
20
Years of Service
User Offline
Joined: 25th Feb 2005
Location:
Posted: 26th Feb 2005 15:26
OK, I think I see one error, but let me make sure I got the rest of it. The error is the next to the last line, should read:

UNTIL KEY$="Y" rather than UNTIL KEY$ "Y"

As for the rest of the code...
The first three lines I'm following. Then we go to the rest...

FUNCTION YESNOENTRY(X,Y,STRING$)

We're telling the program to create a function by the name of YESNOENTRY with the enclosed variables.

REPEAT

Self explanatory

TEXT X,Y,STRING$

OK, I dont really understand the function of this line.

KEY$=INKEY$()
KEY$=UPPER$(KEY$)

These two lines are actually looking for the key input, and converting it to upper case. If it's already upper case, will it not effect it?

UNTIL KEY$="Y" OR KEY$="N"

This is where the repeat starts 'UNTIL KEY = Y or N'

And of course the endfunction returns you to the program.

I think I'm following it correctly, right? Forgive me for this! I was a huge programmer WAAAY back in the Commodore 64 days, and DarkBASIC is extremely close to the C64 commands, minus line numbering. Alot of the commands are identical, but with new or different parameters, and then there, of course, are many that I'm used to that aren't here and vice versa. I'm just trying to learn this, and by going over the code to figure out exactly WHY things are doing what they are doing helps me learn better.

Thanks for the code, by the way!

Cheers,
Namdekan

Login to post a reply

Server time is: 2025-05-23 19:41:36
Your offset time is: 2025-05-23 19:41:36