• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Error -43 when attempting to write to file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error -43 when attempting to write to file


  • Subject: Re: Error -43 when attempting to write to file
  • From: kai <email@hidden>
  • Date: Wed, 17 Nov 2004 00:58:14 +0000

On Tue, 16 Nov 2004 14:47:37 -0800, Mark Butcher wrote:

Aaron

I'm pretty sure you can't define a property in that way. Maybe someone with better understanding of AS will be able to explain it.

You could try this:

global theTargetFile

on log_to_file(myText)
try
set TargetFile to (((path to home folder as string) & "output.txt") as string) as file specification
open for access theTargetFile with write permission
write (myText) to theTargetFile starting at eof
close access theTargetFile
on error errMsg number errNum from objErr partial result errList to errClass
display dialog errMsg & ". Error number: " & errNum & " in log_to_file function" giving up after 3
end try
end log_to_file


Of course, if you only use TargetFile in this handler, you don't need to declare it as a global.

MarkB


On Nov 16, 2004, at 2:24 PM, Aaron Rosenblum wrote:

I wrote this code to write lines to an output file.

I have a property defined at the top of my script:

property theTargetFile : (((path to home folder as string) & "output.txt") as string) as file specification

and then I have this subroutine that logs lines to a file:

on log_to_file(myText)
try
open for access theTargetFile with write permission
write (myText) to theTargetFile starting at eof
close access theTargetFile
on error errMsg number errNum from objErr partial result errList to errClass
display dialog errMsg & ". Error number: " & errNum & " in log_to_file function" giving up after 3
end try
end log_to_file


It is generating the error: "File output.txt wasn't found.. Error number: -43" when some of my users run the script. However, when I run it on my laptop it works fine. Any ideas on why this is happening? Am I creating/setting access to this file the right way? Can I not define this stuff in a property?

Mark is correct, Aaron. When you compile the script on your machine, the property 'theTargetFile' is evaluated using the path to *your* home folder. When the saved script is later run on a different machine, the file path is not recognised there, resulting in a 'file not found' (number -43) error.


If, as Mark suggests, your script specifies the file at runtime, the path to the home folder on the *current* machine should then be correctly identified.

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: can't make droplets with Script Debugger
  • Next by Date: PDF opening in Preview (was Save EPS page from Acrobat)
  • Previous by thread: Re: Error -43 when attempting to write to file
  • Next by thread: can't make droplets with Script Debugger
  • Index(es):
    • Date
    • Thread