Opening a web browser from a SC script

Having trouble using an XCmd or XFcn? Post your questions here.

Opening a web browser from a SC script

Postby fooddoc » Sun Sep 25, 2011 1:31 pm

I have been successfully using someone's old XCMD, LaunchURLX (sorry, can't remember who created this very useful tool!) to open the default web browser from a SC script and pass a url + data string to a website. But this XCMD (as well as several others) that worked fine on a PowerPC Mac does not work on a newer Intel Mac. Does anyone know of a replacement XCmd or Xfcn that I can use that will work in Lion?

Alternatively, I tried a shell command:

do merge("get shell(`open '[[tData]]'`")

but get an error message that the string is >255 chars. I can't shorten the data string - is there any way around this limit?
fooddoc
 
Posts: 8
Joined: Fri Sep 16, 2011 4:43 pm

Re: Opening a web browser from a SC script

Postby Lisa » Sun Sep 25, 2011 3:05 pm

I think the do command is the limiting factor, in terms of character count. But if this is just part of a regular script, I don't see any reason to use do there. Try this:

Code: Select all
get shell(merge("open '[[tData]]'"))
iMac 24" 3.06 GHz Intel Core 2 Duo, 4 GB RAM, Mac OS X 10.6.8, SC 4.7.3
User avatar
Lisa
 
Posts: 303
Joined: Sun Jul 06, 2008 12:33 pm
Location: San Diego, CA

Re: Opening a web browser from a SC script

Postby Dan_Kelleher » Sun Sep 25, 2011 3:36 pm

I'm not sure about an external but the code below should work.
I also commented out a few other examples in the code that you might find useful.
I use this a lot in SuperCard "Docks" to launch files on my computer or go to web sites (see attached image of such a "Dock")

Code: Select all
on mouseUp
--put "http://www.scriptlib.net/" into tloc
--put "open location" &&quote&tloc&quote into turl
--get script(do,AppleScript,turl)
--
--put "http://www.ncbi.nlm.nih.gov/" into tloc
--put "open location" &&quote&tloc&quote into turl
--get script(do,AppleScript,turl)
--
put "http://forums.supercard.us/index.php" into tloc
put "open location" &&quote&tloc&quote into turl
get script(do,AppleScript,turl)
--
--put "MainS120:Applications:SuperCard 4.63:Internals Toolbox:IT Development Guide.pdf" into tFilePath
--put merge("tell app `Finder` to open `[[tFilePath]]`") into tScript
--get script(do,applescript,tScript)
--
--put "MainS120:Applications:SuperCard 4.63:SuperCard UserGuide.pdf" into tFilePath
--put merge("tell app `Finder` to open `[[tFilePath]]`") into tScript
--get script(do,applescript,tScript)
--
--NOTE the next two bits of code are useful to get the path to any file you select onto the clipboard which is useful in --building the "buttons" on the SCard "Dock". You can do the same for pat to a folder you want to open quickly.
--answer file "Please select a file."
--if it is empty then exit mouseup
--else
--put it into tFilePath
--get textToClip(tFilePath) --places the tFilePath on the system Clipboard
--end if
--NOTE the following three line function should be put outside the mouseUp, usually just below it
--function textToClip pString
--get script(do,AppleScript,merge( "set the clipboard to `[[pString]]`"))
--end textToClip
--
end mouseUp


SC project %22Dock%22 of %22buttons%22_.jpg
SC project %22Dock%22 of %22buttons%22_.jpg (62.29 KiB) Viewed 4076 times
Daniel.Kelleher@umassmed.edu
SC4.7.3 OSX 10.7.2 Mac Pro
User avatar
Dan_Kelleher
 
Posts: 438
Joined: Sun Jul 06, 2008 2:45 pm
Location: Worcester (wouster as in would) Massachusetts USA

Re: Opening a web browser from a SC script

Postby fooddoc » Sun Sep 25, 2011 7:04 pm

Thanks to both Lisa and Dan for the quick, and very effective, responses!
fooddoc
 
Posts: 8
Joined: Fri Sep 16, 2011 4:43 pm


Return to Using Externals

Who is online

Users browsing this forum: No registered users and 1 guest