This content has been marked as final. Show 5 replies
Define "doesn't work" :-)
What does the alert tell you about the writeString() status?
I get no error messages, all seems to work fine until you check the text file which still contains nothing!
Assuming you have a *field* named "myField" (adjust type and name as
appropriate), try the following in your authoring environment - there
should be messages in your message window that will help with debugging
on mouseUp me
if objectP(myFile) then myFile = 0
tText = the text of field "myfield"
myFile = new(xtra "fileio")
openFile(myfile, the moviepath & "test.txt", 0)
put "openFile():", status(myFile)
put "setPosition():", status(myFile)
put "writeString():", status(myFile)
alert "Status: "& error(myFile, status(myFile))
myFile = 0
I see where i've gone wrong, i had flash components rather than standard!
I always do that and it always confuses me!
Thanks alot, all working now!
Just a quick note (or two)
1. I'm not sure why you're instantiating Fileio with each exitframe (I wouldn't - you're just using up resources)
2. myFile doesn't need to a global (since you are instantiating and destroying it with each mouseUp - just use a local variable. Let chance of leaks).
3. Consider using a wrapper function (attached below) which you would use like this (and reuse in other projects, or change to use setPref or vList if you later decided to port your project to SHockwave, for example)
res = AppendText("test.txt", member("myfield").text)
put "Appended text result: " & res