Antwise community forums
new Sync methods - Printable Version

+- Antwise community forums (https://forums.antwise.com)
+-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11)
+--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12)
+--- Thread: new Sync methods (/showthread.php?tid=149)



new Sync methods - Vasile - 2023-02-17

To simplify programming and avoid "asynchronous callback hell" it would be nice if Sync methods could be added for ExecuteScript and NavigateWithWebResourceRequest.
Thanks you,
Vasile


RE: new Sync methods - wila - 2023-02-21

Hi Vasile,

Sorry I seem to have missed your question, so my reply is a bit slower than usual.

The version of AntView that was released today has a sync version for NavigateWithWebResourceRequest added, see NavigateWithWebResourceRequestSync.

I'll put the request for a synced version of ExecuteScript on the list.
Note that in the mean time there is a RunAnonymousFunctionSync that you can use instead.

--
Wil


RE: new Sync methods - Bernard Mouille - 2023-02-21

Hello Wil,
Thanks for the new version.
Is it possible to have a thread in this forum where you post when a new version is online ?
Thanks,
Bernard.


RE: new Sync methods - wila - 2023-02-21

Hi Bernard,

Thanks for the question.
I came to the same conclusion earlier today... as we already had a section for the other products.
So added it to the general updates section as a sticky post.

Updates

Still contemplating a bit if it would be better for each section at the forum to have their own updates area.
--
Wil


RE: new Sync methods - Bernard Mouille - 2023-02-21

Thanks Will, it is perfect.
Regards,
Bernard.


RE: new Sync methods - Vasile - 2023-02-22

Hi Willa

> Sorry I seem to have missed your question, so my reply is a bit slower than usual.
Comparing the support offered for other products, the support you provide for AntView is lightning fast. Bravo Wila !

>NavigateWithWebResourceRequestSync
NavigateWithWebResourceRequestSync gives me the opportunity to clean-up my code by removing a lot of timers and the functions they call, asynchronously.
I use AntView activex control, in dBase 2019, to send electronic invoices (xml string) and now this can be done with only 3 lines of code (the server response is a json string).

form.AntView1.nativeObject.NavigateWithWebResourceRequestSync( uri, "POST", xmlString, "Content-Type: application/xml" )
rJsonString = new string()
form.AntViewDocument1.RequestCurrentTextSync( rJsonString )

Very, very simple. Thanks you.

>RunAnonymousFunctionSync
In another project, I use RunAnonymousFunctionSync as often as possible, but I failed when the function had to call another custom function that is defined in the same string.
Example:
// jsString
(p1, p2) => {
a = customFunction1( p1 ) ;
b = customFunction2( p2 ) ;
return a + b ;
}

function customFunction1(x) {
return x ;
}

function customFunction2(y) {
return y ;
}

AntView activex control integrates very well with dBase 2019, parameters can be passed easily
//dbase code, {myVar1, myVar2} is a literal array (1 dimension , 2 elements )
vRet = new string()
form.AntViewDocument1.RunAnonymousFunctionSync(anyIntValue, {myVar1, myVar2}, jsString, vRet)

If there is no additional function declaration in the jsString, the execution succeeds, otherwise it fails.
For these situations I use:
form.AntView1.nativeObject.ExecuteScript(jsString)
// jsString
p1 = "value of myVar1";
p2 = "value of myVar2";
a = customFunction1( p1 ) ;
b = customFunction2( p2 ) ;

function customFunction1(x) {
return x ;
}

function customFunction2(y) {
return y ;
}

That's why I would like there to be a SYNC variant of the ExecuteScript method.

Thanks you
Vasile


RE: new Sync methods - wila - 2023-02-23

Hi Vasile,

I didn't need a reason for adding the feature Smile.
In this case the request was sufficient, but yes that makes perfect sense.
It's on the list, hopefully have some time to look into this soon.

--
Wil