write to file / edit script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

write to file / edit script

Post by robm80 » Fri Aug 08, 2014 12:20 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: write to file / edit script

Post by dunbarx » Fri Aug 08, 2014 2:39 pm

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

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: write to file / edit script

Post by MaxV » Fri Aug 08, 2014 3:49 pm

Use another method:

Code: Select all

put tResults into URL  "file:d:\foo.txt" 
It will be the standard Livecode syntax.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: write to file / edit script

Post by robm80 » Fri Aug 08, 2014 5:51 pm

Sorry,
both advises do not solve the problem.
In the dictionnary there is no such line to empty an opened file.
Rob

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: write to file / edit script

Post by dunbarx » Fri Aug 08, 2014 6:12 pm

What happens if you close the file (with the "close file" command), open it, and then write to it?

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: write to file / edit script

Post by jacque » Fri Aug 08, 2014 7:51 pm

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" 
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: write to file / edit script

Post by robm80 » Fri Aug 08, 2014 8:13 pm

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: write to file / edit script

Post by Simon » Sat Aug 09, 2014 12:37 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: write to file / edit script

Post by robm80 » Sat Aug 09, 2014 3:58 am

Both do it very well :D
Which one to choose :roll:

Lot of thanks
Rob

Post Reply