Page 1 of 1

Saving data to a file

Posted: Thu Jun 26, 2008 12:47 am
by bjb007
I want to save data from an array to
a text file.

I have the file name made up of a text string and
the result of the "seconds" command plus ".txt"

However I can find a way to make this work in
the usual way such as

put url ("file:" & "numbers.txt") into myData
put myData & "27," into myData
put myData into url ("file:" & "numbers.txt")

Any help appreciated.

Posted: Thu Jun 26, 2008 12:54 am
by Nomi
You don't need the & statement in the put url.

I think it would read:

put url "File:numbers.txt" into mydata

and

put myData into url "File:numbers.txt"

- Noel

Saving data to a file

Posted: Thu Jun 26, 2008 7:07 am
by bjb007
Noel

Thanks for the tip.

The problem is, I think, that the file
name I want to use isn't "numbers.txt"
but something like "fred1234.txt" and
it's only available in a variable.

BTW the code I posted above works
for "numbers.txt".

Posted: Thu Jun 26, 2008 7:19 am
by Tim
Try

put myData into URL ( "file:fred" & the seconds & ".txt")

Regards,

Tim

Can any object do this...

Posted: Thu Jun 26, 2008 3:15 pm
by bjb007
Thanks Tim.

Do you know the magic to make Rev
put this file into the same directory
as the app which makes it?

Just an't get my old brain to figure
this out!

Posted: Thu Jun 26, 2008 3:52 pm
by Tim
Here is a little chunk of script that will output the data into a file in the same directory as the engine is running from :

local tFullEnginePath
local tEngineFolder
set the itemdel to ":"
put item -2 to -1 of the address into tFullEnginePath
set the itemdel to "/"
put item 1 to -2 of tFullEnginePath & "/" into tEngineFolder
put myData into URL("file:" & tEngineFolder & "fred" & the seconds & ".txt")

Hope this is what you were after.

Regards,

Tim.