Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 geting an random intiger in a sentance and adding it to a variable
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
pozaj0206




PostPosted: Fri Sep 02, 2011 9:00 pm   Post subject: geting an random intiger in a sentance and adding it to a variable

What is it you are trying to achieve?
I have a file the looks like...
biomeSize:1.5
minMoisture:0.0
maxMoisture:1.0
ECT.
I want to make turing open this file ad get the 1.5 in a variable ad the 0.0 in another 1 ect.


What is the problem you are having?
the 1.5 ad the 0.0 ad whatever else are variable they could be any number when the file is loaded.


Describe what you have tried to solve this problem
I dot know how to approach this problem.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
this is how it wrights to the file


Turing:

procedure Save
    open : stream, "XXXXXXXXXXXXXXXXXXXX.ini", put
    %wrighting the settigs to the file%
    put : stream, "<Biome Mod - All Biome Variables>"
    put : stream, "biomeSize:", item1
    put : stream, "minMoisture:", item2
    put : stream, "maxMoisture:", item3



Please specify what version of Turing you are using
4.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Fri Sep 02, 2011 9:57 pm   Post subject: RE:geting an random intiger in a sentance and adding it to a variable

Do you absolutely have to include 'biomeSize' and 'minMoisture', etc in the input file? You could just have
1.5
0.0
1.0

in the input file and it'd work fine.
pozaj0206




PostPosted: Sat Sep 03, 2011 9:04 am   Post subject: Re: RE:geting an random intiger in a sentance and adding it to a variable

Insectoid @ Fri Sep 02, 2011 9:57 pm wrote:
Do you absolutely have to include 'biomeSize' and 'minMoisture', etc in the input file? You could just have
1.5
0.0
1.0

in the input file and it'd work fine.


yes I do because it is a config file for another program ad there is about 350 of these all with different names
Tony




PostPosted: Sat Sep 03, 2011 9:46 am   Post subject: RE:geting an random intiger in a sentance and adding it to a variable

you can either read one character at a time, and figure things out as you go along, or read the entire line, find colon (with something like index), and split the line into usable parts.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
pozaj0206




PostPosted: Sat Sep 03, 2011 10:30 am   Post subject: Re: RE:geting an random intiger in a sentance and adding it to a variable

Tony @ Sat Sep 03, 2011 9:46 am wrote:
you can either read one character at a time, and figure things out as you go along, or read the entire line, find colon (with something like index), and split the line into usable parts.


Ok ill try that thx Smile
pozaj0206




PostPosted: Sat Sep 03, 2011 10:55 am   Post subject: Re: RE:geting an random intiger in a sentance and adding it to a variable

Tony @ Sat Sep 03, 2011 9:46 am wrote:
you can either read one character at a time, and figure things out as you go along, or read the entire line, find colon (with something like index), and split the line into usable parts.


actually would there be a way for turing to like go to line 1 then right XXX times until it passes the colon the get the numbers and decimal until end of the config line?
(it doesn't matter to me if i have like 10 lines of code for every entry in the config file)
Insectoid




PostPosted: Sat Sep 03, 2011 11:34 am   Post subject: RE:geting an random intiger in a sentance and adding it to a variable

Quote:
it doesn't matter to me if i have like 10 lines of code for every entry in the config file


This is bad. Never say this again. You'll learn bad habits while you give yourself carpel tunnel from typing hundreds of thousands of lines for every program.

You know what a function is, right? Write a function that takes a string as input and outputs an integer. This is probably the easiest way to do it.
pozaj0206




PostPosted: Sun Sep 04, 2011 12:08 am   Post subject: Re: geting an random intiger in a sentance and adding it to a variable

Thanks Insectoid, i never thought about using a function. Smile
ill post how it went later cuz Indiana Jones is on right now :p
+15 bits for you :p
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: