dlwicksell/nodem

SyntaxError: Unexpected token when using function with parameters

Closed this issue · 5 comments

I call a extrinsic function with paremters and get always the following error.

Unexpected token a
at Object.parse (native)
at Object. (/gtm/neo.js:5:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3

The Mumps function is called propertly and the parameters are passed.
Calling without paremeters works without an error.

neo.js
var gtm = require("/gtm/lib/mumps");
var db = new gtm.Gtm();
var ret;
db.open();
ret = db.function({function: 'run^neo', arguments: ['argument1',123]});
console.log("ret=" + JSON.stringify(ret));
db.close();

lothar-joeckel:

First a question, are you using the latest version of Nodem, version 0.3.0? If not upgrade to that, and if so, have you confirmed that everything is set up correctly? Do the other APIs work correctly? For me to test this, I'd need you to send me your code 'run^neo.'

The error you are seeing comes from the JSON parser in Node.js, and means that it isn't valid JSON. I have no problem calling all sorts of different extrinsic functions, with or without arguments, so I'd need your code to debug the issue.

First make sure you are running the latest version, and see if that fixes it. You could run the code in GT.M direct mode first, and show me the output. You can do so like this:

dlw@endor:~/nodem$ mumps -dir

FOIA>w $$function^node("run^neo","9:argument1,4:123")

If you'd like to have me look at this offline, my email address is dlw@linux.com.

Thanks for your interest in Nodem, and hopefully we can figure this issue out and get you going again soon.

Hello David,

thanks for your fast reply.
I'm running node v0.10.17.

Running from direct mode works as ecpected:
ljoeckel@ubuntu1204:/gtm$ gtm
GTM>w $$function^node("run^neo","9:argument1,4:123")
{"ok": 1, "function": "run^neo", "arguments": [argument1,123], "result": "^ARG(1)=argument1 ^ARG(2)=123"}
GTM>

ljoeckel@ubuntu1204:/gtm$ node test.js
{ ok: 1,
function: 'version^node',
result: 'Node.js Adaptor for GT.M: Version: 0.3.0 (FWSLC); GT.M V6.0-003 Linux x86_64' }

SyntaxError: Unexpected token a
at Object.parse (native)
at Object. (/gtm/test.js:7:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
ljoeckel@ubuntu1204:/gtm$

test.js:
var gtm = require("/gtm/lib/mumps");
var db = new gtm.Gtm();
var ret;
db.open();
var version = db.function({function: 'version^node'});
console.log(version);
ret = db.function({function: 'run^neo',arguments: ['argument1',123]});
console.log("ret=" + JSON.stringify(ret));
db.close();

neo.m:
run(arg1,arg2)
set ^ARG(1)=arg1
set ^ARG(2)=arg2
quit "^ARG(1)="^ARG(1)" ^ARG(2)="_^ARG(2)

Hope this helps. If you can confirm that this will run in your environment then there must be a setup problem in my environment.

Kind regards
Lothar

Lothar,

This is a bug in the newest version of Nodem. I know exactly what the problem is, but unfortunately, I am going to be driving all day today, so I can't fix it right now. I should have a new version with a fix for this bug out tomorrow I hope. In the meantime, if you have to, you could go back to the previous version of Nodem, 0.2.1, as it might not have this bug.

I'm sorry about the inconvenience. Again, thanks for your interest in Nodem, and for your patience while I fix this bug.

Hi David,

thank you very much for your enthusasm. This sounds good.
I am very interested in using GT.M together with nodem/node.js.
So will wait for your fix.

Again, thanks a lot for your help.

Kind regards
Lothar

2013/8/28 David Wicksell notifications@github.com

Lothar,

This is a bug in the newest version of Nodem. I know exactly what the
problem is, but unfortunately, I am going to be driving all day today, so I
can't fix it right now. I should have a new version with a fix for this bug
out tomorrow I hope. In the meantime, if you have to, you could go back to
the previous version of Nodem, 0.2.1, as it might not have this bug.

I'm sorry about the inconvenience. Again, thanks for your interest in
Nodem, and for your patience while I fix this bug.


Reply to this email directly or view it on GitHubhttps://github.com//issues/5#issuecomment-23413217
.

I have pushed out version 0.3.1, which I believe has fixed the bug that you uncovered.