Launch command alternatives

FlexibleLearning at aol.com FlexibleLearning at aol.com
Tue Aug 26 04:28:01 EDT 2003


on launchURL tURL
  # tURL can be a local file path, a web URL or an eMail address.
  local tResult=""
  if ("@" is not in tURL) and ("www." is not in tURL) and (there is not a 
file tURL) then
    get smartAnswer("Error","This document cannot be found.","OK")
    exit to top
  end if
  if (char 1 to 4 of tURL is "www.") then put "http://" before tURL
  else if (tURL contains "@" and "mailto:" is not in tURL) then put "mailto:" 
before tURL
  switch the platform
  case "MacOS"
    if "http://" is in tURL or "mailto:" is in tURL then
      send tURL to program "Finder" with "GURLGURL"
    else
      replace "/" with ":" in tURL
      if char 1 of tURL is ":" then delete char 1 of tURL
      put quote&"Finder"&quote into tApp
      put quote&tURL&quote into tURL
      put "tell application"&& tApp &cr&\
          "open file"&&tURL &cr&\
          "end tell" into tScript
      do tScript as AppleScript
      if "error" is in the result then put the result into tResult
    end if
    break
  case "Win32"
    set the hideConsoleWindows to true
    put empty into tApp
    if ("NT" is in the systemVersion) then
      set the shellCommand to "cmd.exe"
      put quote & quote into tApp
    end if
    get shell("start" && tApp && quote & tURL & quote)
    if the result is not empty then put the result into tResult
    break
  end switch
  if tResult is not empty then
    get smartAnswer("The following error is reported",tResult,"OK")
  end if
end launchURL


/H


_________________________________________________
Hugh Senior
The Flexible Learning Company
Consultant Programming & Software Solutions
Fax/Voice: +44 (0)1483.27 87 27
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20030826/230f7ad2/attachment.html>


More information about the use-livecode mailing list