applescript error "can't make...into constant type"

What does it mean when I get the error

"Finder got an error: Can't make "Photo [Data]: Archive error LOG:" into tpe constant."

from the following script:

tell application "TextEdit"
activate
tell application "Finder" to set visible of process "TextEdit" to false
tell application "Finder"
set LogFileName to first item of fileErrorList
set {oldDelims, my text item delimiters} to {my text item delimiters, "."}

set LogFileName to first text item of LogFileName & ".rtf" as string
set my text item delimiters to oldDelims
set LogFolder to (path to "Photo [Data]:Archive error LOG:" as string)--THE SCRIPT GETS HUNG UP HERE

set theLogFile to (LogFolder & LogFileName)
set theRealLogFile to POSIX path of theLogFile


end tell

This is a small part of a larger script, but I think the rest of the script is OK. I can post the rest if necessary.

Thanks.

Peter

G5 Mac OS X (10.4.9)

Posted on Apr 11, 2007 6:51 AM

Reply
4 replies

Apr 11, 2007 8:42 AM in response to Peter Robertson

I think you'll find that the 'path to' is redundant, since you seem to be building the path yourself.

Suppose you were putting your log into the desktop folder, you could get the path of that folder with

path to desktop folder

which would return a fully qualified path, but note that the term 'desktop folder' is not quoted, which means it's a constant that AppleScript understands: hence your error. (AppleScript does not know what your string is referring to.)

Apr 11, 2007 10:25 AM in response to Peter Robertson

The path to command takes as its argument one of a number of known standard locations such as 'desktop', 'home folder', 'preferences', etc. and returns their path in the current system.

Many of these paths will change based on the environment (e.g. hard drive name, current username, etc.) which is what makes them impossible to hard-code into the script.

Your script is asking the path to command to return the path to "Photo [Data]: Archive error LOG:" which isn't one of its known locations, hence it fails.

If your disk name is 'Photo [Data]', then what you have is the path, so you don't need the 'path to' command. The script should work as:

<pre class=command>set LogFolder to "Photo [Data]:Archive error LOG:"</pre>

Apr 12, 2007 7:42 AM in response to Camelot

I tried using

set LogFolder to "Photo [Data]:Archive error LOG:"

but I still get a TextEdit window asking me where I want to save the file and what name I want to save it as. I thought the script was doing this with

tell application "Finder"
set LogFileName to first item of fileErrorList
set {oldDelims, my text item delimiters} to {my text item delimiters, "."}

set LogFileName to first text item of LogFileName & ".rtf" as string
set my text item delimiters to oldDelims
set LogFolder to "Photo [Data]:Archive error LOG:"

set theLogFile to (LogFolder & LogFileName)
set theRealLogFile to POSIX path of theLogFile


end tell

set text of document 1 to "The following files were NOT archived on" & space & todayDate & ":" & return & return & the_items
save document 1 in theRealLogFile--why doesn't this work??

This is part of a larger script, but I pretty sure I've isolated the problem to this part.

Peter

Peter

Apr 12, 2007 12:48 PM in response to Peter Robertson

>but I still get a TextEdit window asking me where I want to save the file and what name I want to save it as. I thought the script was doing this with

TextEdit's dictionary states that the in parameter needs to be an alias. you're passing it a POSIX path. They are not the same.

Try:

<pre class=command>save document 1 in file theLogFile</pre>

Since theLogFile is a Mac-style path to where you want to save the file, it should work. POSIX paths are only needed when dealing with shell-level commands, not most GUI apps.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

applescript error "can't make...into constant type"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.