Finding the disk name

Sarah sarahr at genesearch.com.au
Sun Aug 31 18:05:01 EDT 2003


>> In the newer version of Revolution, running under OS X, when I get a
>> file name (say from answer file), I get something like this:
>> /Users/sarah/Documents/FolderName/Filename.txt
>> This is fine and Rev reads such a file perfectly. The problem arises
>> when I want to pass a filename to an AppleScript, which requires a 
>> full
>> path including the disk name, in this form:
>> Sarah HD:Users:sarah:Documents:FolderName:Filename.txt
>
> Perhaps using POSIX file in your AppleScript what you need.  An 
> example:
>
> set myPath to "/Users/trevordevore/desktop/"
> set myPath to POSIX file myPath
> display dialog newPath
>
> This would display "Macintosh HD:Users:trevordevore:Desktop:
>
> Would this solve your problem?
>
Thanks Trevor,

That nearly worked :-) Here is the function I came up with to translate 
a Rev file path to an AppleScript path:

function filePathToAppleScript pFile
   put "set tFilePath to *file*" & cr & "set tAS to POSIX file 
tFilePath" \
       & cr & "return tAS" & cr into tScript
   replace "*file*" with quote & pFile & quote in tScript
   do tScript as Applescript
   put the result into tASfile
   delete word 1 of tASfile  -- file
   delete char 1 of tASfile  -- quote
   delete char -1 of tASfile -- quote

   return tASfile
end filePathToAppleScript

Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/




More information about the use-livecode mailing list