Computer Science Canada Loading .txt Files |
Author: | TheXploder [ Fri Feb 06, 2004 5:58 pm ] | ||
Post subject: | Loading .txt Files | ||
I got this mostly from the help file, then I made a text file with the name "test.txt" and saved a few words in it, but when I press enter, and add some more words and run the program a strange box char appers, can I get rid of that?
|
Author: | Andy [ Fri Feb 06, 2004 6:00 pm ] |
Post subject: | |
y r u using read? thats for binary plus u have to save ur source in the same folder as ur txt file |
Author: | Mazer [ Fri Feb 06, 2004 6:01 pm ] |
Post subject: | |
The problem is that you are trying to add text to a binary data file. You could have a program to write to the file in binary, but it would best not to edit the file in notepad or something. |
Author: | Dan [ Fri Feb 06, 2004 6:05 pm ] | ||
Post subject: | |||
i am gussing that whould repprestent a "\n" or a line break. i am not shure what u are doing but i think that it whould be eaer with put and get file i/o unless u are trying to do somting more comapliated then i think. ex of get/put i/o for files from turing doc:
|
Author: | TheXploder [ Fri Feb 06, 2004 6:10 pm ] |
Post subject: | |
the thing is that I just wanna load strings out of a text file... I do have them saved in the dame folder... I just want to load it and read, almost like: var words : array 1..10, 1..10 of string I don't intend to change the array within the program at all... just load the info I need... |
Author: | Mazer [ Fri Feb 06, 2004 6:15 pm ] |
Post subject: | |
OK, but it would still be easier to just use get, especially if that's all you'll be doing with it. |
Author: | TheXploder [ Fri Feb 06, 2004 6:20 pm ] |
Post subject: | |
get, doesn't that make a person write something in? and I don't want that... |
Author: | Andy [ Fri Feb 06, 2004 6:21 pm ] |
Post subject: | |
no... if u do get:fid,line u get from the txt file |
Author: | TheXploder [ Fri Feb 06, 2004 6:26 pm ] | ||
Post subject: | |||
why doesn't this work?
|
Author: | Dan [ Fri Feb 06, 2004 6:32 pm ] |
Post subject: | |
b/c u are not using get right.....see this: http://www.compsci.ca/v2/viewtopic.php?t=5 |
Author: | TheXploder [ Fri Feb 06, 2004 6:50 pm ] | ||||
Post subject: | |||||
ok, I tryed it and I still have difficulty:
my text file has this in it:
|
Author: | Andy [ Fri Feb 06, 2004 7:56 pm ] |
Post subject: | |
whats wrong wit it? |
Author: | TheXploder [ Fri Feb 06, 2004 8:02 pm ] | ||
Post subject: | |||
I changed the code a bit, now it works, but exept for the fact that the top line is cut off somehow..:
|
Author: | Andy [ Fri Feb 06, 2004 8:07 pm ] |
Post subject: | |
cuz u got it before the loop |
Author: | TheXploder [ Fri Feb 06, 2004 8:09 pm ] |
Post subject: | |
ohh, lol, thx |
Author: | TheXploder [ Fri Feb 06, 2004 8:37 pm ] | ||
Post subject: | |||
I added some more code now it adds the value loaded to a two dimensional array, yay now I'm done my game... because all you need is numbers it's all about numbers every game is made with arrays full of numbers like CS, anyway, can I shorten that any further..?
|
Author: | Andy [ Sat Feb 07, 2004 12:34 pm ] | ||
Post subject: | |||
the last for loop is useless.. just output it rite after you save it
??? strint (number (i) (i2)) number is a 1 d aray |
Author: | santabruzer [ Sat Feb 07, 2004 1:33 pm ] |
Post subject: | |
it's probably string manipulation... or something of the sort... of the array |
Author: | Andy [ Sat Feb 07, 2004 1:41 pm ] |
Post subject: | |
oooo... y didnt he just get one character at a time from the txt file? |
Author: | santabruzer [ Sat Feb 07, 2004 1:43 pm ] |
Post subject: | |
i have no idea.. and that would be so much simpler and more efficient *decides that he is not gonna write it* |
Author: | TheXploder [ Sat Feb 07, 2004 1:44 pm ] |
Post subject: | |
I am going to create a map out of this, so you need the x, y position of every integer.. |
Author: | Andy [ Sat Feb 07, 2004 1:45 pm ] | ||
Post subject: | |||
yea...
and he's done |
Author: | TheXploder [ Sun Feb 08, 2004 3:34 pm ] | ||
Post subject: | |||
Dodge, I don't understand how your code works, could you write a complete source that also loads a file.. Anyway I got another probelem I want to open map.txt files that are in another folder:
|