revBrowserCallScript

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

revBrowserCallScript

Post by Dixie » Wed Mar 09, 2011 1:24 pm

Hi...

Has anyone got any experience of using 'revBrowserCallScript' ... all I can get out of it is :-

Code: Select all

global browserID

on mouseUp
   get revBrowserCallScript (browserID, "codeAddress" )
   put the result
end mouseUp
execution error at line n/a () near "-[WebUndefined cStringUsingEncoding:]: unrecognized selector sent to instance 0x17064190"

I would really like to be able to call a javaScript function in the revBrowser. Any help appreciated.

thanks...

Dixie

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: revBrowserCallScript

Post by Mark » Mon Mar 14, 2011 3:42 pm

Hi Dixie,

You need to replace your parameter "codeAddress" with valid JavaScript syntax, for example "codeAddress();".

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: revBrowserCallScript

Post by Dixie » Wed Mar 16, 2011 6:59 pm

Mark...

Thanks for the reply... unfortunately, using your suggestion does not work :(

get revBrowserCallScript (browserID, "codeAddress();" )

be well,

Dixie

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: revBrowserCallScript

Post by GSPearson » Thu Feb 19, 2015 2:53 pm

Any update to this with code samples. I am using LC 7.0 and the project I am working on I would love to do this to turn on and off a map layer that has school buildings locations within it. When I call this the error I get is

Button :Button": execution error at line /na/ (External; handler: exception) neqar "unknown browser if"

Code: Select all

global gBrowserID
on mouseUp
get revBrowserCallScript(gBrowserID, DisplayAlert(), "Testing from Livecode")
end mouseUp
gBrowserID has an value of 11011524

The card that draws the map defines this value that gBrowserId has and within the button I get the same value for gBrowserID


Any Ideas?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: revBrowserCallScript

Post by Mark » Thu Feb 19, 2015 3:22 pm

Hi,

Is DisplayAlert() a JavaScript function? Try putting it in quotes.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: revBrowserCallScript

Post by GSPearson » Thu Feb 19, 2015 7:36 pm

Yes on the page within the web server has

Code: Select all

<script type="text/javascript">
     function DisplayAlert(txt) {
          alert(txt);
     }
</script>
When I put the DisplayAlert() within quotes, The error message I get is

"unknown browser id"

However in my variables tab of editor, gBrowserID has a value of 5441464. This button which calls the function through revBrowserCallScript and the gBrowserID is set within the openCard script.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: revBrowserCallScript

Post by Mark » Thu Feb 19, 2015 7:56 pm

Hi,

5441464 is a very high number for a browser ID created with revBrowser. Are you sure that gBrowseID has been declared as a global variable? Can you check where this number comes from exactly?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: revBrowserCallScript

Post by GSPearson » Thu Feb 19, 2015 8:19 pm

On the Map Card here is the script

Code: Select all

global gScreenSize, gScreenCenterLoc, gResizeStackHorizontal, gResizeStackVertical, gDeviceHasNetworkConnection, gDeviceHasInternetConnection
global gServerName, gMainApplicationArchiveFilename, gMainApplicationFilename, gSplashAppVersion, gApplicationPrefsDir, gProgramAppUpdateArray
global gMainAppDownload, gMainAppExtracted, gOrgAvailableMarketsArray, gOrgAvailableMarketTowersArray
global gAreaBTALatitude, gAreaBTALongitude, gAreaCallSign, gAreaCity, gAreaState
global gDecLatitude, gDecLongitude, gBrowserID

on openCard
   local tMapURL
   put "Viewing Map for: " into field "Map Heading" on me
   put gAreaCity & "," && gAreaState && "(" & gAreaCallSign & ")" after field "Map Heading"
   
   -- If any open browsers lets close them
   resetCard
   
   -- Create the Browser Object
   lock messages
   put the windowID of this stack into gBrowserID
   unlock messages
   
   if gBrowserId is not an integer then
      answer "Failed to open browser"
   else
      -- This links or sets the rec area of the browser to the rec area of the BrowserBackground
      put gServerName & "/LivecodeApps/EBSLicenseMapApp/MapDisplay.cfm?" into tMapURL
      put "CLat=" & gDecLatitude & "&" after tMapURL
      put "CLon=" & gDecLongitude & "&" after tMapURL
      put "MarkerTitle=" & gAreaCallSign after tMapURL
      put revBrowserOpen(gBrowserID, tMapURL) into tBrowserID
      revBrowserSet tBrowserID, "rect", the rect of image "BrowserArea"
      -- revBrowserSet lBrowserID, "url", tMapURL
   end if
end openCard

on preOpenCard
   
end preOpenCard

on resetCard
   -- Clears the browser from the screen and memory
   closeBrowsers
   
   -- Set top Full Width
   set the rect of image "BrowserArea" to 14,28,1014,702
end resetCard

on closeBrowsers
   -- Close all browser in memory
   repeat for each item gBrowserID in revBrowserInstances()
      revBrowserClose gBrowserID
   end repeat
end closeBrowsers

on closeCard
   closeBrowsers
end closeCard
Then on the button which is on the same card the code is

Code: Select all

global gScreenSize, gScreenCenterLoc, gResizeStackHorizontal, gResizeStackVertical, gDeviceHasNetworkConnection, gDeviceHasInternetConnection
global gServerName, gMainApplicationArchiveFilename, gMainApplicationFilename, gSplashAppVersion, gApplicationPrefsDir, gProgramAppUpdateArray
global gMainAppDownload, gMainAppExtracted, gOrgAvailableMarketsArray, gOrgAvailableMarketTowersArray
global gAreaBTALatitude, gAreaBTALongitude, gAreaCallSign, gAreaCity, gAreaState
global gDecLatitude, gDecLongitude, gBrowserID

on mouseUp
   get revBrowserCallScript(gBrowserID, "DisplayAlert()", "Testing from Livecode")
   put the result into it
end mouseUp

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: revBrowserCallScript

Post by GSPearson » Thu Feb 19, 2015 8:25 pm

I changed tBrowserId into gtBrowserID and on the

Code: Select all

get revBrowserCallScript(gtBrowserID, "DisplayAlert()", "Testing from Livecode")
the error is:

button "Button": execution error at line n/a (External handler: exception) near "error in script"

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: revBrowserCallScript

Post by Mark » Thu Feb 19, 2015 8:41 pm

Hi,

gBrowserID is not the windowID. It is the output from revBrowserOpen.

Code: Select all

put revBrowserOpen(the windowID of this stack,"") into gBrowserID
Now, gBrowserID should start at 1 and increase by 1 every time you create a new browser instance.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: revBrowserCallScript

Post by GSPearson » Thu Feb 19, 2015 8:56 pm

In tracing the code, I got gBrowserID which starts with 1 and does increase by 1 each time a new map is displayed within the image rectangle.



I changed the Javascript to not use a parameter and it does work.

Code: Select all

on mouseUp
get revBrowserCallScript(gBrowserID, "DisplayAlert")
   put the result into it
end mouseUp

Now to try and figure out the parameters of the javascript function

Post Reply

Return to “Internet”