Revolution filepath to Applescript file: how to?

Ken Ray kray at sonsothunder.com
Tue Aug 2 16:13:58 EDT 2005


On 8/2/05 2:12 PM, "Joel Guillod" <joel.guillod at net2000.ch> wrote:

> Ken ,
> 
> Yes, I would be pleased to get your conversion routine.
> 
> My problem is that I dont know exactly know how to convert in MacOSX
> (MacOS9?)
> from: "/Users/toto/Desktop/Image 6.png"
> to: "Main HD:Users:toto:Desktop:Image 6.png"
> or from: "/Volumes/My Device/toto/Image 6.png"
> to ...?

Here you go:

on mouseUp
  put stsConvertPath("/Users/toto/Desktop/Image 6.png",":")
end mouseUp
 
--> Main HD:Users:toto:Desktop:Image 6.png



function stsConvertPath pPath,pDestType
  switch pDestType
  case "POSIX"
  case "/"
    -- assumes colon-delimited full path with drive name as first item
    replace "/" with tab in pPath
    replace ":" with "/" in pPath
    replace tab with ":" in pPath
    set the itemDel to "/"
    delete first item of pPath
    if char 1 of pPath <> "/" then put "/" before pPath
    return pPath
    break
  case "COLON"
  case ":"
    if isOSX() then
      -- assumes slash-delimited full path with
      -- root drive name not appearing
      if char 1 to 9 of pPath = "/Volumes/" then
        set the itemDel to "/"
        put item 3 of pPath into tHD
        -- leave the preceding "/" it's used in concatenating the path below
        delete item 2 to 3 of pPath
      else
        -- root path
        put line 1 of the drives into tHD
      end if
      replace ":" with tab in pPath
      replace "/" with ":" in pPath
      replace tab with "/" in pPath
      put tHD & pPath into pPath
    else
      replace "/" with ":" in pPath
      if char 1 of pPath = ":" then delete char 1 of pPath
    end if
    return pPath
    break
  end switch
end stsConvertPath

Have fun...

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the use-livecode mailing list