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 / from # to $ -is it possible?

Author
Message
Uriel The Ignoble
21
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 14th Jun 2003 02:30
im trying to make a numeric variable occur in the program in responce to user input... but the compiler says $ and # are not compatable. I know these are seperate variable types, but i dont understand why they arent compatable if they are not both in the same condition. (right now its set like this:
If input$ = "1" then characterhealth# = 100
Is there another way to make numeric variables effected by input?

im trying to make a menue when u start the game that lets you select a character class (like an RPG) and this selection changes your stats.
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 14th Jun 2003 02:49
Here's how to convert between the two.

From $(string) to #(float)
float# = val(string$)

From #(float) to $(string)
string$ = str$(float#)

This should work though.
If input$ = "1" then characterhealth# = 100
You could try adding a .0 at the end of characterhealth# like this:
If input$ = "1" then characterhealth# = 100.0

"Food is güd!" -Dean
"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
GameKit
21
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 16th Jun 2003 00:09
hmmm... mabey try something like...

if input$="1"
characterhealth#=100.0
endif

...if that doesn't work i don't know what will...

Anyone Can Destroy...But Few Can Create...
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Jun 2003 06:37
Probably down to the way DB lets you (or used to let you) use reserved words as variable names.

Try using I$ instead of input$ to see if that works:

If I$ = "1" then characterhealth# = 100

TDK
Bloodshot
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location: United Kingdom
Posted: 21st Jun 2003 22:51 Edited at: 21st Jun 2003 23:03
I've created an example here of using the Ascii codes of keys to make choices, assuming I've understood what you're trying to do correctly and you're asking the user to make choices with keypresses:

i.e.

User, please press a key to choose to be either a (F)ighter or a (M)age

Angel
21
Years of Service
User Offline
Joined: 27th Jun 2003
Location: United States
Posted: 22nd Jul 2003 18:28
Use the commands val() and str$()
example:
A$ = "1000"
A = VAL(A$)
B$ = STR$(A)
print B$

Wanna Go On A Data???

Login to post a reply

Server time is: 2024-09-20 15:51:12
Your offset time is: 2024-09-20 15:51:12