In the loop, I call oWebView:Eval() and try to process the results in the Result() function. However, it does not work out in any way
- Code: Select all Expand view RUN
- #include "FiveWin.ch"
function Main()
private oDlg, oWebView
DEFINE DIALOG oDlg TITLE "This is a dialog" COLOR "N/B" SIZE 400, 200
@ 3, 8 BUTTON "Test" ACTION Start()
ACTIVATE DIALOG oDlg ON INIT oDlg:Cargo:={0,0} CENTERED
return nil
function Html()
local cHtml
TEXT INTO cHtml
data:text/html,
<html>
<head>
<meta charset="UTF-8" >
</head>
<body style="background-color:cyan">
<button id="bt" style="display:none;">the test is completed</button>
<script>
function Test(num) {
SendToFWH(num) ;
} ;
function ViwB() {
el=document.getElementById("bt").style.display="" ;
} ;
</script>
</body>
</html>
ENDTEXT
return cHtml
procedure Start
local st
if valtype(oWebView)!="O"
oWebView := TWebView():New()
oWebView:SetSize(800, 200)
oWebView:bOnBind = { | cJson, nCalls | Result(cJson) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( Html() )
endif
for st=1 to 5
oWebView:Eval("Test("+ltrim(str(st))+")" )
? oDlg:Cargo[1], oDlg:Cargo[2]
oDlg:Cargo[1]:=oDlg:Cargo[2]
next
? oDlg:Cargo[2]
oWebView:Eval("ViwB()" )
return
function Result(num)
local dat
Hb_JsonDecode(num, @dat)
oDlg:Cargo[2]+=dat[1]
? "C", oDlg:Cargo[2]
return