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 / The first noob question!

Author
Message
apocaliv
17
Years of Service
User Offline
Joined: 6th Dec 2006
Location:
Posted: 12th Nov 2008 14:07
Good morning,
i'm learning Dark Basic from the beginning. I have the first problem (question) now!

If i have a variable named var and is equal to 5 how can i print something like this?:

var=5
Print "The value is VAR, bye bye" (Where var is the value of the variable)

How can i print the value of a variable in a string? If i write as before i see not the value but VAR. Can you help me?

Sorry for the bad english!
I wait your asnwer.
Best Regards
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Nov 2008 14:39 Edited at: 12th Nov 2008 14:41
print "The value is " + str$(var) + " , bye bye"


as long as var is of type int

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Captain IceT
16
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Boat Murdered, and Im still laughing!
Posted: 14th Nov 2008 19:23
You could also:


or:


"Dwarf Fortress has taught me that all the world's problems would be substantially reduced had our parent civilizations never minted more than four stacks of coins."
- DwarfFortressWiki
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 16th Nov 2008 22:56
or
like what they said
Print "The value is ", VAR, ", bye bye!"

text X coord, Y coord, "The value is "+str(VAR)+", bye bye!"


www.freewebs.com/outscape
Tom0001
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location:
Posted: 17th Nov 2008 12:38 Edited at: 17th Nov 2008 12:39
Actually, Outscape, that line should be:

text x co-ordinate, y co-ordinate, "The value is "+str$(VAR)+", bye bye!"

(The $ is very important, as it is what converts the 'VAR' variable to a String.) o.o

Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 18th Nov 2008 21:22
o yea typo shouldof added that


www.freewebs.com/outscape
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 22nd Nov 2008 23:58 Edited at: 22nd Nov 2008 23:59
Using the PRINT command:

PRINT "The value is ",var,", bye bye"
or
PRINT "The value is ";var;", bye bye"

Using the TEXT command:

Text Screen X Position, Screen Y Position, "The value is "+str$(var)+", bye bye"

***************************************************************

The STR$(number) command converts a number into text (a.k.a. a string) so you can print it to the screen. This new text number is returned, so if you wanted to you could put it into another variable (it would need to be a string variable though). The original number variable is not affected. This command is not necessary when using the PRINT command.

Login to post a reply

Server time is: 2024-11-25 15:01:35
Your offset time is: 2024-11-25 15:01:35