LC has to be the tool, because the app being deployed to HTML5 is a very extensive GUI codebase written in LC and used on desktop.stam wrote: Wed Jan 18, 2023 3:14 am I wasn't asking what javascript method you're trying to replicate in LC. I was asking what the overall intention of what you're doing is - because if you think LiveCode is a good fit for whatever it is you're doing, then maybe there is a better LiveCode way of doing it. If not, then perhaps LC is the wrong tool for the job.
Several things. One is to use a JavaScript client for large OpenAPI, which is autogenerated from the spec via an OpenAPI generator. There is no LCScript generator for OpenAPI (google "list of openapi generators", I can't post the link), and writing one is a very laborious undertaking. Manually writing LCScript client functions would be laborious and error-prone, and they'd quickly fall outdated (as the APIs are updated regularly updated). So I'd like to call autogenerated ones, necessitating JS.stam wrote: Wed Jan 18, 2023 3:14 am Again, what is it you're trying to do? …
I'm curious what this "IO" is... and why this "IO" cannot be done in LC script?
stam wrote: Wed Jan 18, 2023 3:14 amIf it really can't, can LC script not take over some of the state you're trying to maintain?
The issue with calling stateful JS code would be that the state comes from JS, either a JS object or a context, which as noted above will not survive stringification. LCScript can only call JS via "do as javascript", which only returns strings. That's a limitation, but I believe I can call this JS code statelessly (for now). The issue that currently blocks me is that the JS calls are asynchronous (they return via a callback or Promise).jacque wrote: Wed Jan 18, 2023 12:15 am I'm out of my depth here but you can store anything you like in script local or global variables. I'd assume you can store the state of something that way. Someone who knows more about what you're trying to do may have an answer, I hope they'll chime in.
How could "script variables" or "send in time" synchronize a "do as javascript" that does not return a value, but merely causes a JS callback to be executed in the JS environment some time later? AFAICT they can't.stam wrote: Wed Jan 18, 2023 3:14 amPromises and await could theoretically be resolved by using script variables and "send in time" or some such.
Do you want an explicit example? I'm calling a JS function like one of these:
Code: Select all
function returnsImmediately (argFoo, argBar, callbackFunction) { ... }
async function returnsPromise (argFoo, argBar) { ... }
Code: Select all
do "JSON->stringify(someSyncFunction(" & argFoo & "," & argBar & ))" as "javascript"
put JsonImport(result()) into myVar