Re: Error opening file
Re: Error opening file
- Subject: Re: Error opening file
- From: Lachlan Deck <email@hidden>
- Date: Tue, 14 May 2002 11:57:23 +1000
Hi there,
From: Christopher Coulon <email@hidden>
I am having trouble discovering why I can't get this to work. When I
attempt to following script:
set macroName to "*rodentHeart.obj.2.04a"
set macroPath to "/GAIA/*Test Macros"
tell application "Finder"
select item macroName of macroPath
open selection
end tell
I get the following error at the 'select item macroName of macroPath'
line:
Execution Error
Can't make "*rodentHeart.obj.2.04a" into a integer.
Two problems:
Problemo 1...
The problem is that the keyword "item" is used for lists.
E.g., if you had a list of items item 3 would be the third one in the
list.
Solution: remove item from your command
Problemo 2...
your macoPath is in a POSIX format which is great for the Terminal - but
not for other AppleEvent commands.
You need to use ":" as your folder delimiter in place of "/"
So,
set macroName to "*rodentHeart.obj.2.04a"
set macroPath to "/GAIA/*Test Macros"
set theFile to replace_chars(macroPath, "/", ":") & ,
":" & macroName
tell application "Finder"
try
open theFile as alias
on error the error_message number the error_number
beep
display dialog "Error: " & the error_number & ". " & ,
the error_message buttons {"OK"} default button 1
end try
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
---------
or just change your macroPath to use ":"'s instead and then you don't
need to replace_chars.
Even if you plan on using (do shell script ...) stuff (i.e., scripting
shell command line stuff) it is better to declare your paths in
AppleSpeak terms and convert to POSIX when needed.
e.g.,
set MacroPath to "MyHD:Users:MyUserName:Documents:"
set MacroName to "Binff.txt"
...
set this_file to MacroPath & MacroName
display dialog (do shell script "cat " & (POSIX path of this_file))
tell app "Finder"
open this_file
end tell
The macroName and macroPath refer to valid names and paths, so why the
error?
Again the path is not valid in AppleEvent speak.
with regards,
--
Lachlan Deck
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.