Calling JavaScript RETURN function in LC Browser

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Calling JavaScript RETURN function in LC Browser

Postby BarrySumpter » Wed Apr 25, 2012 1:19 am

This works the fist time the ControlDo execute firest.
But on second execute it stalls n returns "error"

If anyone has a thought could you please let us know?




Code: Select all
<html>
<head>
<script type="text/javascript">

function myfunction(txt)
{
alert(txt);
}

function myfunction2()
{
alert('Who Dat Be?');
}

function calculate(a,b,c) {
   d = (a+b) * c;
   return d;
}

</script>
</head>
<body>

<form>
<input type="button" onclick="myfunction('Hello')" value="Call function">
</form>

<p>By pressing the button above, a function will be called with "Hello" as a parameter. The function will alert the parameter.</p>

</body>
</html>



Code: Select all
on doCallBrowserFunction
   
   --MobileControlDo sBrowserId, "execute", "myfunction('sup dude!')" 
   --MobileControlDo sBrowserId, "execute", "myfunction2()"   
   MobileControlDo sBrowserId, "execute", "result=calculate(4,5,9)"   
   
   answer the result
   
end doCallBrowserFunction
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
BarrySumpter
 
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Calling JavaScript RETURN function in LC Browser

Postby sturgis » Wed Apr 25, 2012 1:42 am

With this very simple script embedded in a web page I can use mobilecontroldo sBrowserId, "execute", "getRandom();"
and as you say, when it works it does what its supposed to. the result contains .. well.. the result. Sometimes it will work 10 or 12 times in a row for me then for some reason it will fail with a long 10 to 12 second lock after which the result contains "error." Other times it fails on the first or second try.

Code: Select all
<script type="text/javascript">

function getRandom() {
return Math.floor(Math.random()*11)
}

</script>

It doesn't seem to matter WHAT is being returned. I even just had the function return the same string every time ("Hello") with the same issues. It works then it doesn't. Reloading the same page sometimes makes it work again, sometimes not.

Has anyone tried this on IOS, and does it work correctly there? I'm thinking there is something up with the android version of mobilecontroldo execute. My other thought is maybe there is something going on with the mobile browser control itself, but have seen javascripts working flawlessly in the browser instance itself so am leaning towards the former as the most likely.

Any suggestions to fix this/get around this would be very welcome.
sturgis
Livecode Opensource Backer
Livecode Opensource Backer
 
Posts: 1680
Joined: Sat Feb 28, 2009 11:49 pm

Re: Calling JavaScript RETURN function in LC Browser

Postby BarrySumpter » Wed Apr 25, 2012 1:52 am

Trying this now:


Code: Select all
   select group "Browser"
   
   copy group "Browser" to this card
   set the name of it to "Browser2"
   
   if exists(group "Browser2") then
      answer "Browser2 exists!"
   else
      answer "Nope! Browser2 DOES NOT exist!"
   end if
   
   
   
   MobileControlDo "Browser2", "execute", "myfunction('sup dude!')"   
   MobileControlDo "Browser2", "execute", "myfunction2()"     
   MobileControlDo "Browser2", "execute", "calculate(4,5,9)"   



Doh! Sooo close. But Nope! Doesn't work.
Tried all kinds of variations.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
BarrySumpter
 
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Calling JavaScript RETURN function in LC Browser

Postby Saman Sjr. » Mon Jul 17, 2017 10:03 am

it still happen this day..... :cry:

LC 8.1.5
Windows 7 64bit
Android 5.1.1
SDK 25.2.5
JDK 1.8.0
Saman Sjr.
Livecode Membership
 
Posts: 37
Joined: Sat Nov 30, 2013 6:40 am


Return to Android Deployment

Who is online

Users browsing this forum: No registered users and 1 guest