How to pass variable data between AppleScript and Revolution?

Sarah sarahr at genesearch.com.au
Wed Oct 9 17:15:01 EDT 2002


Forget using Explorer (or any browser). Rev can retrieve the html page 
all by itself and put it in a variable or field for you to parse. This 
gives you a cross-platform system that doesn't rely on your user's 
having any other software installed.

	put URL "http://www.runrev.com/index.html" into field "Download"

This is the basic syntax. You can also use "load URL" to download the 
page in advance for quicker access. Don't forget that fields can 
display basic html:
	set the htmlText of field "Display" to field "Download"

Although this would be my preferred way to solve your problem, in 
answer to your AppleScript questions:

1. idle handlers are not recommended. Instead have a look at the docs 
for the send command if you need a repeating event. You can set up a 
handler that does the AppleScript and then say: send "getWebPage" to me 
in 10 seconds
Put this as the last line of the getWebPage script and it will keep 
repeating but without slowing down the rest of your system.

2. When you "do" an AppleScript, it can end in a "return" that sends 
back it's final data. After the "do" command, check "the result", for 
whatever the AppleScript returned.

3. Multi-line AppleScripts are best handled by storing the script in a 
custom property or hidden field. Then you can "do" the field or 
property. If you need to set variables in the AppleScript first, use 
placeholders and replace them with the variable before doing. Here is 
an example (untested but the theory works fine :-):

In a custom property of a button called "checkForProcess"

tell application "Finder"
	set processList to the processes
	if processList contains ***myApp*** then
		return "App is running"
	else
		return "App NOT running"
	end if
end tell

In the button, have this script:

on mouseUp
	put the checkForProcess of my into theScript
	replace "***myApp***" with quote & "Mail" & quote in the Script
	do theScript
	answer the result
end mouseUp


Cheers,
Sarah


On Thursday, October 10, 2002, at 07:13  am, RGould8 at aol.com wrote:

> Jan/Ken & the listserve,
>
>      Thanks so much for your assistance in answering my AppleEvent 
> questions.  Your answer has prompted me to think more about how I was 
> approaching the issue, and now I'm wondering if I even need to use 
> AppleEvents at all, if I can execute the AppleScript right from within 
> Revolution.
>
>      Ok, last Applescript question for the day, I believe.  I've 
> learned so much in the past 1/2 hr on this list - - it's been great.
>
>      My ultimate goal is to write a Revolution app that:
>
> 1)  Launches Internet Explorer to a specific URL  ( The web-pages have 
> lots of tables, and I need e-commerce security on these pages, 
> otherwise I'd attempt displaying the pages in Revolution itself)
> 2)  Detects when the user has landed on a certain page
> 3)  Send the html text of that page back to Revolution for parsing
>
> I presently have an AppleScript that runs an "idle" loop, constantly 
> checking the title of the page within Internet Explorer, and when it 
> detects the specific page I'm looking for, Applescript captures the 
> HTML text from that page.
>
> I'm wondering if I can eliminate the whole need to "sublaunch" the 
> AppleScript App as a separate "self-running app", and just run the 
> script itself within Revolution.
>
> There are 3 gotchas that I can think of:
>
> 1)  Can I use an on-idle handler within Revolution that launches an 
> AppleScript, so that I don't have to use Applescript's on-idle 
> handler.  Would one be any better than the other?
>
> 2)  Once AppleScript captures the html text from Internet Explorer, 
> how can I get that data back to a variable in Revolution?  Is there 
> some sort of variable-passing language between Applescript and 
> Revolution?  Or are AppleEvents the solution for passing variable data 
> between AppleScript and Revolution?
>
> 3)  Is there a way to get a fairly large Applescript into a "do 
> script" command?  The one-line-at-a-time-&-return method could get 
> rather painful.





More information about the Use-livecode mailing list