Page 1 of 1
write to file / edit script
Posted: Fri Aug 08, 2014 12:20 pm
by robm80
open file "d:\foo.txt"
write tResult to file "d:\foo.txt"
This gives no problem when "d:\foo.txt" is empty. But when foo.txt is not empty yet: how to script that file empty
Why I have to wait 5 seconds at least, when clicking edit script
Is there no other way to edit a script?
In my previous programmer live you could rightclick a button for that

Rob
Re: write to file / edit script
Posted: Fri Aug 08, 2014 2:39 pm
by dunbarx
You can simply write empty to the file. Please read the dictionary under the "write to file" command for the several options associated with this. Look closely at the comments, and experiment with these.
I edit controls by holding down "Cmd-Opt" and clicking on the control. You can also use the inspector, or execute a command "edit script of object...". I have no idea why there should be any delay. Which method are you using? The inspector? Anyone else ever see this delay?
Craig Newman
Re: write to file / edit script
Posted: Fri Aug 08, 2014 3:49 pm
by MaxV
Use another method:
Code: Select all
put tResults into URL "file:d:\foo.txt"
It will be the standard Livecode syntax.
Re: write to file / edit script
Posted: Fri Aug 08, 2014 5:51 pm
by robm80
Sorry,
both advises do not solve the problem.
In the dictionnary there is no such line to empty an opened file.
Rob
Re: write to file / edit script
Posted: Fri Aug 08, 2014 6:12 pm
by dunbarx
What happens if you close the file (with the "close file" command), open it, and then write to it?
Craig
Re: write to file / edit script
Posted: Fri Aug 08, 2014 7:51 pm
by jacque
robm80 wrote:In the dictionnary there is no such line to empty an opened file.
This way:
Code: Select all
put empty into url "file:d:\foo.txt"
Re: write to file / edit script
Posted: Fri Aug 08, 2014 8:13 pm
by robm80
Code: Select all
close file "d:\Livecode\Lijsten.txt"
open file "d:\Livecode\Lijsten.txt"
write empty to file "d:\Livecode\Lijsten.txt"
no reaction
Re: write to file / edit script
Posted: Sat Aug 09, 2014 12:37 am
by Simon
Hi Rob,
Just a small missing thing;
Code: Select all
open file "c:\Livecode\Lijsten.txt" for write
Just change that line in the above code and it all works (with a close file as a last line).
Simon
Re: write to file / edit script
Posted: Sat Aug 09, 2014 3:58 am
by robm80
Both do it very well
Which one to choose
Lot of thanks
Rob