Hi David
I found an example how to use an AB Script function return code in JS here in the forum. What about the other way around?
Is it possible to use the return value of a JS Custom Function in an AB Script?
Hi David
I found an example how to use an AB Script function return code in JS here in the forum. What about the other way around?
Is it possible to use the return value of a JS Custom Function in an AB Script?
Hello Harald,
If I understand well, we must deep into Javascript to do something like that, in other words, we must execute the JS function inside the StartJS and EndJS actions. So, for example, the below code is perfectly valid:
So the "MyJSFunction" can contain a "return" like we can see below, remember this is a JS return, not a Return action, since we are inside a JS function, not an AB function.
Then if we execute the first code, our "FunctionResult" variable store "Here is the result!".
Thanks!
I used a custom JS function in the Function Manager instead with
But in fact it is good to know both ways for max. flexibility.
Hello Harald,
Sure. It's possible to write code like the above, and using the function's result:
Both are the same. Except maybe that your one don't set the "isPWA" variable if the condition don't allow. So maybe you finally write a code like the below one:
Which is also good... however, if the "pwaPlatformPWA" function return "true" or "false"... then maybe use the function's result directly can be better, don't you? Finally we only need the below line of code:
However, even the above can be discussed... because, is that code more legible than the previous one? That is, reading the previous one code we can deduce that the function result is a boolean one, and, we know what the variable "isPWA" in any case. On the contrary, this last line of code don't tell us what finally the "isPWA" variable is... yes... it's the result of the function... but what result it is?
Maybe adding a comment line above the code... so it's our choice! :-)
Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.
Este sitio utiliza "cookies" útiles para almacenar sus preferencias.