Tuesday, July 14, 2020

#1 2002-12-12 07:47:14 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

writing to files

ok this is probably a really dumb question but my application is dumping a file into a text view then after the user edits it dumps it back out to the file...
the file is an admin file for a cvs repository so therefore is unix based...
my problems arise when i attempt to open the file for writing i get a duplicate file name error...

set l_file to open for access l_fName with write permission

and then when i remove the file and start from scratch when i  write to my new file i seem to get a unicode output which i have no idea how to convert to the desired format....

write l_contents to l_file

does anybody have any solutions??
thanks


One mans trash is another mans treasure

Offline

 

#2 2002-12-12 08:07:24 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

Re: writing to files

ok this is probably a really dumb question but my application is dumping a file into a text view then after the user edits it dumps it back out to the file...
the file is an admin file for a cvs repository so therefore is unix based...
my problems arise when i attempt to open the file for writing i get a duplicate file name error...

set l_file to open for access l_fName with write permission


It's rough trying to determine what might be going wrong without seeing more of the code. Does the script ever close the file?

Offline

 

#3 2002-12-12 09:01:21 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: writing to files

i close the file directly after writing.....
here is the entire function

-- g_cvsignore is a posix style path
on saveFile(theObject)

set l_toSave to contents of text view "txt_text" of scroll view "txt_text" of window of theObject
   
set g_cvsignore to (POSIX file g_cvsignore)
   
set l_file to open for access (g_cvsignore as text) with write permission

set eof of l_file to 0

write (l_toSave as string) to l_file

close access l_file

set visible of window of theObject to false
end saveFile


One mans trash is another mans treasure

Offline

 

#4 2002-12-12 10:13:23 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

Re: writing to files

As near as I can tell, you are trying to open a string for access (g_cvsignore as text). What happens if you change this line:

Applescript:

set l_file to open for access (g_cvsignore as text) with write permission

To this?

Applescript:

set l_file to open for access file (g_cvsignore as text) with write permission

Offline

 

#5 2002-12-12 10:29:14 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: writing to files

yeah, i feel a bit stupid after that....
it's working perfectly now....
rob, you da man....


One mans trash is another mans treasure

Offline

 

#6 2002-12-12 10:41:16 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

Re: writing to files

yeah, i feel a bit stupid after that....
it's working perfectly now....
rob, you da man....


Nah, not stupid at all. It's easy to overlook little things like that when you stare at the code for too long and frustration sets in.  :shock:

Glad it helped to have some fresh eyes. big_smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)