This content has been marked as final. Show 9 replies
What is on Dean's tutorial is about as simple as it gets. If you used
that to work with, then you are probably very close to making it work.
Can you post your code or give a clue as to where it is failing?
To insert a return in a text member:
sprite(x).member.text = "This is line 1" & RETURN & "This is line 2"
RETURN is a key word that represents a new line character and the
ambersand (&) is the string concatentor.
> Hey everyone, iv really been having trouble working with File IO, im 99%
> complete on my project, everything works but it doesnt save to file like i need
> it to, iv got a test file off deansdirectortutorials.com or something like
> that, which just has a simple interface allowing u to write to, append, and
> open a file that gets saved. iv literally copied the code word for word from
> his (made changes where appropriate) and mine just doesnt work. does anyone
> know a nice simple method of doing them, i really need to learn how to do it
> asap. any help you guys could give would be fantastic.
> also a little less important thing, when entering info in from the code, i
> want to change the text of a sprite, so i put in sprite(x).member.text = " etc
> etc, is there a way of doing a 'return' in the code, as in, like hitting the
> enter key so it puts the remainder of the text on a new line?
> thanks everyone
Summarizing Dean's tutorial, to create a file and save text to it you
need to issue the following commands:
scribe = new (xtra "FileIO")
createFile (scribe, the moviePath&"Multimedia.txt")
openFile (scribe, the moviePath&"Multimedia.txt", 0)
writeString (scribe, "Exporting text in Director is easy!")
Line 1 creates an instance of the FileIO xtra and assigns a reference to
it to the variable named scribe
Line 2 using the instance created in Line 1 to create a file named
"Multimedia.txt" which is created in the same folder that the movie is
Line 3 opens the file for writing
Line 4 writes text to the open file
Line 5 closes the file
Line 6 disposes on the instance created in Line 1
I am not the greatest in Director, but I ran into a similar problem in a project a few moths ago, it turned out that I forgot to set my "movie script" code. I just wanted to throw that in there...maybe thats what you are missing.
myFile = new(xtra "fileio")
myFile = 0 -- Dispose of the instance
Hope it works!
hey guys, im still having ridiculous troubles with it, i just cant get it to work for the life of my, iv followed the deans tutorial thing down to a tee, but everytime i try to read from the file i just get <void>
it does the same when i copied wot u guys have written and when i try to copy the code from the pre built file on the website, any suggestions?
iv just had another thought, the data that im going to be saving to the file is a set of lists, as this is the way im planning on making the program and its pretty vital that it still saves the lists correctly
basically if u can imagine iv got
namelist [john, dave, simon]
surnamelist [thomas, peters, morris]
how will it actually save it, cos iv just looked at the file it makes and thats just a static text file, but if the lists have to repopulate themselves from the text then that will return them all as strings wont it? some of them have to be numbers in order for some of my program to work.
The only reason I can imagine that it isn't working is if you are
running it from a new movie that you have not yet saved. If that is the
case then "the moviePath" will be null, and trying to write or read a
file without a fully qualified path will fail.
Where exactly does it fail? Line 1? Line 2?
Yes, saving a list with fileIO converts it to a string. There is a free
Xtra that will allow you to save lists (and other data types) without
converting to strings.
By the way, I don't believe propSave Xtra has been updated for D11.
Dave C wrote:
> Yes, saving a list with fileIO converts it to a string. There is a free
> Xtra that will allow you to save lists (and other data types) without
> converting to strings.
its fine, iv got it, wooooo im really happy to have that working, i needed to make a txt file for each list but it works, so im happy, cheers guys