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.

Newcomers DBPro Corner / Defining a key? / Return float, integer, string?

Author
Message
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 6th Feb 2003 20:00
Hello, friends,

I would like to know how you define a key. I am currently working on my third version of CS de_DBP (CODE SNIPPETS : COUNTER-STRIKE BOMB/DEFUSE!) and I need it so the user can select 1 of 3 languages. It would work something like this:

COUNTER-STRIKE BOMB/DEFUSE!

Select a language :
Choisir une langue :
Wählen Sie eine Sprache aus :

English = e
Français = f
Deutsch = g


Then the user would press e for the English, f for the French and g for the German version respectively, and the program uses GOSUB to jump to the corresponding language.

Apparently I should use INKEY$, SCANCODE and KEYSTATE function but it doesn't explain them very well in the reference manual.

This brings me to the second question. In the reference manual the syntax for these commands are like this:

Return String=INKEY$()
Return Integer=SCANCODE()
Return Integer=KEYSTATE(Scancode)

I understand what integers and strings are, I believe floats are real numbers, but what the heck is the return part?

Please would someone also tell me how I use these commands?

Thanks in advance,
Daz
DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Feb 2003 20:42
Ignore the word 'Return' and it should be easy to understand.

for example:
x$=inkey$()

This will get the current keypress into the variable x$. If no key was pressed then x$ will be empty.
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 6th Feb 2003 20:47
Wow, thanks for the explanation and the quick reply, really appreciated.

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Feb 2003 20:48
Ahh! Another satisfied customer
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 15:42
Actually, no, I still can't figure it out, could you do an example for each code so I can get the jist of it?

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 15:57
Being a 100% n00b sux

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 16:14
No it doesn't!

You could try something like this :



You would need to replace each scancode with the correct one.

An alternative way would be along the lines of :



Inkey$ waits until a key is press (and only a limited set too), scancode returns the scancode of a key pressed, and keystate returns 1 if the key corresponding to given scan code is being pressed or not.

It should be noted that I've got a DLL that aside for letting the user select which keys they want for any given function, it can also detect some keys that DBPro cant, if I remember correctly.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 16:20
uhhhhhh.......O_o ???
Me no know cases yet...

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 16:23
How about :

if scancode()=1
<do something>
else
if scancode()=67
<do something else>
endif
endif

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 18:47
I don't think that would work because you need the KEYSTATE() command, right?

Anyway, could you show me how I could use the commands to print something on the screen so I can get the jist of it?

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 19:35
Okay, here's an example :



Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 19:42
That's good, toad, but there comes a time where I need to find out the numbers for the scancode, so could you show me another PRINT example, but when I press a key, it prints out the number on screen?

Chou. Thanks in advance.

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
soap_shoes
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United States
Posted: 7th Feb 2003 19:44
wouldnt you need to use an "input" code?

things take time......like golf...
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 19:54
No, when the key is pressed, it will automatically do what I want it to do. With an INPUT command, the user has to press the letter then RETURN, which I don't want to happen.

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 19:55
BTW, IanM and MrTAToad will both be credited in the final version.

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 20:39
okay, you can do it one of two ways, either use the following code :

do
print scancode()
sync
loop

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 20:40
or rip the codes out of my function mapper - as thats got extra codes.

The former will be easier of course...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 20:50
Cheers, man, that is such a simple code I'm shocked I didn't get it, anyway thanks, my project will be complete in a few mins hopefully.

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 21:06
TIS IS DONE, go to the Code snippets section...

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 21:30
Okay, my code stinks. If any key other than the ones chosen by the SCANCODE() is pressed it starts the English version. Take a look:



I know it's the WAIT KEY, so how do I change it to the 3 ones I want only?

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 21:38
Try this instead :



Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 22:05
Nah, same thing, man, plus the GOTO command stinks. It's definitely the WAIT KEY bit that's the problem. That either needs to be removed and replaced or something. Any ideas, Oh respected toad?

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 22:23
Try this instead then (after getting rid of the wait key)



Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 7th Feb 2003 22:29
Now only the English version works, HELP!

P.S. I'm glad you're still bothered to help me

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Feb 2003 23:43
Heres the full code. Works fine here :



Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 8th Feb 2003 23:31
Yes, I was messing about trying to see if I could use those commands and I wasn't far off. However, when trying to achieve that I added more commands to colour the text. Now when I do it a blank, black screen appears. Try it:



This lost n00b asks for your favour once again. I'm not going to learn this language any time soon, am I?

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 9th Feb 2003 00:05


Try that - the INK command is INK foreground colour,background colour

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Daz
21
Years of Service
User Offline
Joined: 26th Dec 2002
Location: United Kingdom
Posted: 9th Feb 2003 00:17
Argh! Perfect now, but am I going wrong somewhere? Take a look, these are out of the DBP help files :

SET TEXT OPAQUE
This command will set the background of the current text settings to the color of
the background ink.

SYNTAX
SET TEXT OPAQUE
SET TEXT OPAQUE


INK
This command will set the current ink color using the specified color value. color
values range from 0 to over 16 million, that represent every combination of red,
green and blue to make up the final color. You can use the RGB command to make
the generation of the color value straight forward. The parameter should be
specified using integer values.

SYNTAX
INK Foreground Color,Background Color


So, you see, my code should've been correct, or aren't I getting something? If I was right, I was missing out on getting the rest of the code done myself because of THEM. Oh well, thanks for the help. I'll post it in my dead thread over in CODE SNIPPETS...

DarkBASIC Professional is the best programming utility.
8/10 Housewives agree!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 10th Feb 2003 00:55
I dont think you were right there, mainly because the background colour was black...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!

Login to post a reply

Server time is: 2024-09-19 03:14:02
Your offset time is: 2024-09-19 03:14:02