forums

TNT Basic Forums > Programming Q&A
Passing variables to data statements?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-18-2004 20:02

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Hi,
Is it possible to pass a variable to a data statement inside the same procedure, and then read from it later on?
This is of use to me because I have a loop that scans through a text input by the user and gives feedback based around it. I need it to store information from two variables and read from them later. The only way around this is to have a variable for each item, which I don't want to do because of the unessecary length and complexity. If I were able to write to data statements I could store two pieces of information in the same statement which would also simplify the part of the AI where I need to read from the data.

04-18-2004 20:12

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

I don't think you can write new things into your program while it is actually running... Better use the variables.

04-21-2004 12:19

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

That's what I thought, thanks for the information.
It looks although the most effective way for me to store the data now is in a text file, but I don't have a lot of luck with those in TNT. Does anyone know of a simple example of a game using a text file to store information, and read from them later? Also, with the ask create file command, is it necessary to know the name of the file in order to open it, as this is part of the syntax in the create file command; how do you get the file name the user has chosen when they typed it in the dialogue?

04-21-2004 22:35

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

I don't think you can get the file name that the user chooses. You only get the file ID number, and that doesn't do you any good if you want to open it up later; you need the name, not the id!
That's why you use ask open file. The player knows the name of the file.

04-28-2004 18:23

Posted by:
eric

Location:
earth

Click Here to Email eric   Find more posts by eric

I have done some RPG text driven in the past, is this what you are working on?. Be a bit more specific, to what you want to do.

07-18-2004 22:55

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

Hmm...

I'm pretty sure you can do:

Procedure MyProc()
int age
string name
int newage
string newname

age=5
name="Mark"

read ageCopy
read nameCopy

print nameCopy , ageCopy

' this data statement contains variables
data age, name

End Proc

Basically you can put any variables into data statements and it will take the value of the variable when you execute the read command.

Hope this helps,

Mark

07-18-2004 23:27

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Hey Mark is back!

Hum I never thought of trying that...

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.