Tip of the day: AppleScript with Properties to pass file path
// we have some FolderItem
dim f as FolderItem = SpecialFolder.Desktop.Child("test.key")
// and build a script
dim lines() as string
// here we declare a property for the script:
lines.Append "property filePath : """""
// and convert path from posix file path to AppleScript path
lines.Append "tell application ""Finder"""
lines.Append " set f to filePath as POSIX file"
lines.Append "end tell"
// and use path for Keynote
lines.Append "tell application ""Keynote"""
lines.Append " activate"
lines.Append " set mydoc to open file f"
lines.Append "end tell"
// compile the script
dim s as String = Join(lines, EndOfLine.Macintosh)
dim a as new AppleScriptMBS
a.Compile s
if a.Lasterror <> 0 then
MsgBox str(a.Lasterror)+" "+a.Error.BriefMessage
end if
// fill the property
a.ScriptPropertyValue("filePath") = f.NativePath
// run it
a.Execute
if a.Lasterror <> 0 then
MsgBox str(a.Lasterror)+" "+a.Error.BriefMessage
end if