On Fri, 1 Feb 2008 18:52:28 +1000, Ian Wood wrote:

> Oops. Just discovered that the above function doesn't cope with file 
> paths that contain any kind of quote mark.
> 
> The following function should work better, escaping characters rather 
> than putting quote marks around the whole path.

Here's the function I use, which works for both Mac and Windows:

function stsFormatPath pPath,pPlatform
  -- assumes a full "/"-delimited path
  switch pPlatform
  case "MacOSX"
  case "Unix"
    put "\" & space & quote & "'`<>!;()[]?#$^&*=" into tSpecialChars
    repeat for each char tChar in tSpecialChars
      replace tChar with ("\" & tChar) in pPath
    end repeat
    break
  case "Win32"
    set the itemDel to "/"
    put item -1 of pPath into tFile
    put "\/:*?" & quote & "<>|" into tSpecialChars
    repeat for each char tChar in tSpecialChars
      replace tChar with ("-") in tFile
    end repeat
    put tFile into item -1 of pPath
    replace "/" with "\" in pPath
    break
  end switch
  return pPath
end stsFormatPath

Hope this helps,

Ken Ray
Sons of Thunder Software, Inc.
Email: [EMAIL PROTECTED]
Web Site: http://www.sonsothunder.com/
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to