Computer Science Canada File I/O to String |
Author: | Pa|2a|)oX [ Fri Feb 18, 2005 9:52 pm ] |
Post subject: | File I/O to String |
Hello, Just wondering if there is a way to make a variable equal to the values in a text file. i.e. A text file has the value 100101001 made from seperate variables using the put : function. I need another string variable to be equal to that value. Thanks for any help. |
Author: | Cervantes [ Sat Feb 19, 2005 8:02 am ] |
Post subject: | |
read up on get . |
Author: | Pa|2a|)oX [ Sat Feb 19, 2005 10:30 am ] |
Post subject: | |
I already have, and unfortunately it does not answer my question. The tutorial shows how to retrieve prestored variables with the same name. I need to make a variable equal to the entire line of the file. Thanks |
Author: | Cervantes [ Sat Feb 19, 2005 10:45 am ] |
Post subject: | |
Okay, so instead of assigning each line to your variable (:=) add each line to your variable (+=). Also putting : * after your get might be useful (it gets the entire line, including spaces). |
Author: | Pa|2a|)oX [ Sat Feb 19, 2005 11:13 am ] | ||
Post subject: | |||
awesome, i just figured it out and came here to post results.. thanks for you help anyways ![]() this is just an example:
|
Author: | Cervantes [ Sat Feb 19, 2005 11:38 am ] | ||
Post subject: | |||
You are only getting one line though. I thought you wanted it all? Well, this works since you've only got one line in that file, but try adding a few lines after it. See what happens? total only equals the last line. Let's fix it:
|
Author: | MysticVegeta [ Sat Feb 19, 2005 8:43 pm ] |
Post subject: | |
Dont you think the "exit when eof(streamin)" line should be over the "get :" line incase there is no first line in the data file. ![]() |
Author: | Pa|2a|)oX [ Sat Feb 19, 2005 9:44 pm ] |
Post subject: | |
Thanks, but i needed the output file for a very simple thing. One line to put, one line to get. Its my multiplication porgram, you can check it out here: http://www.compsci.ca/v2/viewtopic.php?t=7848 |
Author: | MysticVegeta [ Sat Feb 19, 2005 9:59 pm ] |
Post subject: | |
I think errortraping the "ask" thing will make it cool, cause if i put in "qwe" it will still exit lol ![]() |
Author: | Pa|2a|)oX [ Sat Feb 19, 2005 10:35 pm ] |
Post subject: | |
Hey what happened to all my posts and submissions? |
Author: | Pa|2a|)oX [ Sun Feb 20, 2005 9:32 am ] |
Post subject: | |
Wow that was weird, all of a sudden almost all my posts and programs dissapeared and my post count went down from lik 12 to 6, now everything is back to normal except my posts ![]() I will try to error trap that exit question a bit better after I'm done the other two programs, I'm just about done subtraction. |