Quote from victor on October 17, 2023, 10:27 pmi have jscript func that parese json like this
json = '{"result":true, "count":42}';
obj = JSON.parse(json);and when i try to get the parsed json as var with this
publication.nbSetVar "[%1]", obj.count
the error hapend and say ! Expected ';'
i also add ; end of code
publication.nbSetVar "[%1]", obj.count;
still same error but the publication.nbSetVar is work in vbscript correctly
may be in jscript must do some thing elese
let me know how its must be
i have jscript func that parese json like this
json = '{"result":true, "count":42}';
obj = JSON.parse(json);
and when i try to get the parsed json as var with this
publication.nbSetVar "[%1]", obj.count
the error hapend and say ! Expected ';'
i also add ; end of code
publication.nbSetVar "[%1]", obj.count;
still same error but the publication.nbSetVar is work in vbscript correctly
may be in jscript must do some thing elese
let me know how its must be

Quote from luishp on October 19, 2023, 11:51 am@victor the problem you are describing is a bit difficult to understand. Can you please share a simple app showing the problem?
Thank you!
@victor the problem you are describing is a bit difficult to understand. Can you please share a simple app showing the problem?
Thank you!
Quote from victor on October 19, 2023, 2:36 pmyes i upload test app and the functions file
simply its is a jscript json parser and the script tested in nodejs and had no error
only error i get is when try to get resault of prsed json as variable in visualneowin
( btwy if there is any better way to parse json in visualneowin let me know im using external cmd app for parse json ( like JQ ) but its slow down the project )
tnks for help :)
yes i upload test app and the functions file
simply its is a jscript json parser and the script tested in nodejs and had no error
only error i get is when try to get resault of prsed json as variable in visualneowin
( btwy if there is any better way to parse json in visualneowin let me know im using external cmd app for parse json ( like JQ ) but its slow down the project )
tnks for help :)
Uploaded files:
Quote from luishp on October 19, 2023, 6:36 pm@victor I think you should consider using this awesome plugin:
https://tropicdesigns.net/ezjson-plugin.html
Regards.
@victor I think you should consider using this awesome plugin:
https://tropicdesigns.net/ezjson-plugin.html
Regards.
Quote from victor on October 19, 2023, 7:50 pmok tnk you it seems good plugin
and what about that jscript?
i mean i get error even on other jscripts not only this one when i try to use publication.nbSetVar
can u give me an example to use publication.nbSetVar in jscripts
because in vbscripts work witout problem but in js i get error say [! Expected ';']
and tnks for helping this
ok tnk you it seems good plugin
and what about that jscript?
i mean i get error even on other jscripts not only this one when i try to use publication.nbSetVar
can u give me an example to use publication.nbSetVar in jscripts
because in vbscripts work witout problem but in js i get error say [! Expected ';']
and tnks for helping this
Quote from Gaev on October 20, 2023, 5:01 am@victor
and what about that jscript?
i mean i get error even on other jscripts not only this one when i try to use publication.nbSetVar
can u give me an example to use publication.nbSetVar in jscriptsHere is a demo javascript function that takes a number passed as the first parameter in a Call command, adds one to it, and stores the result as a VNWin variable ... and then displays this variable (using AlertBox) from within the javascript function.
// showcase to get, set and execute in javascript functions function jsGetSetExec(a){ var b = a+1; nbSetVar("[gk]",b); nbExecAction('AlertBox "b=" "[gk]"'); } jsGetSetExec([inputNumber]);In the Function parameters section, please add ...
Alias: [inputNumber] Type: Number Description: number passed as inputYou can name this function file whatever you desire; just use the same name as the first parameter in your Call command.
and what about that jscript?
i mean i get error even on other jscripts not only this one when i try to use publication.nbSetVar
can u give me an example to use publication.nbSetVar in jscripts
Here is a demo javascript function that takes a number passed as the first parameter in a Call command, adds one to it, and stores the result as a VNWin variable ... and then displays this variable (using AlertBox) from within the javascript function.
// showcase to get, set and execute in javascript functions
function jsGetSetExec(a){
var b = a+1;
nbSetVar("[gk]",b);
nbExecAction('AlertBox "b=" "[gk]"');
}
jsGetSetExec([inputNumber]);
In the Function parameters section, please add ...
Alias: [inputNumber] Type: Number Description: number passed as input
You can name this function file whatever you desire; just use the same name as the first parameter in your Call command.
Quote from Gaev on October 20, 2023, 5:04 am@victor
because in vbscripts work witout problem but in js i get error say [! Expected ';']
I think it is because javascript (unlike vbscript) does not support a count method ... there are a few examples on the internet that show how you can get a count of the number of key/value pairs in a JSON object ... if you can not find them (using Google search), just holler and I will post links.
because in vbscripts work witout problem but in js i get error say [! Expected ';']
I think it is because javascript (unlike vbscript) does not support a count method ... there are a few examples on the internet that show how you can get a count of the number of key/value pairs in a JSON object ... if you can not find them (using Google search), just holler and I will post links.
Quote from Gaev on October 20, 2023, 5:32 am@victor
Another example that also demos nbGetVar ...
a) attach this code to a button ...
SetVar "[gkStringIn1]" "abcd" SetVar "[gkStringIn2]" "wxyz" Call "jsDemo2" AlertBox "gkStrinOut" "[gkStringOut]"b) make this content of function file jsDemo2 ...
// showcase to getVar and setVar in javascript functions jsInput1 = nbGetVar( "[gkStringIn1]" ) jsInput2 = nbGetVar( "[gkStringIn2]" ) jsOutput = jsInput1 + "..." + jsInput2; nbSetVar("[gkStringOut]",jsOutput);
Another example that also demos nbGetVar ...
a) attach this code to a button ...
SetVar "[gkStringIn1]" "abcd" SetVar "[gkStringIn2]" "wxyz" Call "jsDemo2" AlertBox "gkStrinOut" "[gkStringOut]"
b) make this content of function file jsDemo2 ...
// showcase to getVar and setVar in javascript functions
jsInput1 = nbGetVar( "[gkStringIn1]" )
jsInput2 = nbGetVar( "[gkStringIn2]" )
jsOutput = jsInput1 + "..." + jsInput2;
nbSetVar("[gkStringOut]",jsOutput);