go to url

Ray Horsley ray at linkitonline.com
Tue Dec 6 21:27:11 CST 2005


Fascinating handler, Ken.  Thanks!  Just one thing.  Where is the  
function isOSX() located?  I don't seem to have that in any of the  
libraries.

Thanks,

Ray Horsley
Developer, LinkIt! Software


On Dec 6, 2005, at 12:36 PM, Ken Ray wrote:

> On 12/1/05 1:01 PM, "Rick Rice" <rrice at tru.ca> wrote:
>
>> All I want to do is have a link in a field that when clicked will
>> launch a browser and go to the url.
>> I have spent the last evening and most of this morning searching and
>> trying things like:
>>
>> start using "liburl"
>> go url "http://www.google.ca"
>>
>> No luck
>> Can anyone provide the correct script?
>> script needs to be cross platform.
>> I'm using MC2.5 Mac OS X 3.9
>
> Sure, Rick, I have one that supports going to a url in a browser,  
> launching
> your mail client and addressing an email to someone, and opening AOL  
> Instant
> Messenger (or iChat) and starting an IM session (along with doing  
> 'gopher',
> but hardly anyone uses that anymore). It's more than you asked for, so  
> cut
> out whatever you don't need (watch for line wraps):
>
> on stsGoURL pURL
>   put char 1 to offset(":",pURL) of pURL into tProtocol
>   if (char 1 to 6 of pURL = "file:/") and (char 7 of pURL <> "/") then
>     -- convert to local path with three ///
>     replace "file:/" with "file:///" in pURL
>   else
>     put "file:,http:,mailto:,gopher:,aim:" into tProtocols
>     if tProtocol is not among the items of tProtocols then
>       -- assume web
>       put "http://" & pURL into pURL
>       put false into tIsIM
>     end if
>   end if
>   switch (the platform)
>   case "MacOS"
>     if isOSX() then
>       get shell("open" && q(pURL))
>     else
>       do ("open location" && q(pURL)) as AppleScript
>     end if
>     break
>   case "Win32"
>     put (word 1 of the systemVersion is "NT") into tIsNT
>     if $COMSPEC <> "" then
>       set the shellCommand to $COMSPEC
>     else
>       if tIsNT then
>         set the shellCommand to "cmd.exe"
>       else
>         set the shellCommand to "command.com"
>       end if
>     end if
>     switch tProtocol
>     case "mailto:"
>       put  
> queryRegistry("HKEY_CLASSES_ROOT\mailto\shell\open\command\") into
> tMailApp
>       -- replace placeholders for all Win versions (%1 for non-XP  
> modern, %l
> for old, %ProgramFiles% for XP)
>       replace q("%1") with pURL in tMailApp
>       replace "%1" with pURL in tMailApp
>       replace q("%l") with pURL in tMailApp
>       replace "%l" with pURL in tMailApp
>       replace "%ProgramFiles%" with $PROGRAMFILES in tMailApp
>       open process tMailApp for neither
>       break
>     case "aim:"
>       -- Example:
>       --    aim:goim?screenname=binentertainment&message=This+is+a+test
>       put
> queryRegistry("HKEY_LOCAL_MACHINE\Software\classes\aim\shell\open\comma 
> nd\")
> into tAIMApp
>       replace q("%1") with pURL in tAIMApp
>       replace "%1" with pURL in tAIMApp
>       open process tAIMApp for neither
>       break
>     default
>       put word 1 of
> queryRegistry("HKEY_LOCAL_MACHINE\Software\classes\http\shell\open\comm 
> and\"
> ) into tBrowserPath
>       if tIsNT then
>         set the hideconsolewindows to false
>         open process (tBrowserPath && q(pURL)) for neither
>       else
>         get shell(tBrowserPath && q(pURL))
>       end if
>       break
>     end switch
>   end switch
> end stsGoURL
>
>
> Use it like:
>
>   stsGoURL "http://www.sonsothunder.com/"
>   stsGoURL "mailto:kray at sonsothunder.com"
>   stsGoURL "aim:goim?screenname=SonsOThndr&message=This+is+a+test"
>
> Have fun!
>
> Ken Ray
> Sons of Thunder Software
> Web site: http://www.sonsothunder.com/
> Email: kray at sonsothunder.com
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>



More information about the metacard mailing list