I am new to web development. Coming from Delphi / pascal. My long-term goal is to transform an outdated application into a web environment. (I am using this application: http://smartmobilestudio.com/ to cross compile pascal into javascript, but this should not affect this question). My legacy program uses synchronous remote procedure calls (RPC) for the server. I use EWD.js technology ( http://robtweed.wordpress.com/2014/01/23/ewd-js-on-fhir/comment-page-1/ ), which makes asynchronous calls through node.js. I read a lot of posts here about synchronous synchronous calls. And I’m afraid that I’m just out of luck if I can’t get EWD to act synchronously. But I want to understand this better.
Consider this pseudo code:
RPCcall
RPCCall
RPCCall
If any of the RPC calls fail, the entire application should fail. I read about “continuation style” coding, which I suppose is that every asynchronous call tells where to get the patch after completion, when the onMessage handler calls the callback function after receiving the return message:
MyProc()
RPCCall(<name>,MyProc_2);
end;
MyProc2()
RPCCall(<name, MyProc_3);
end;
MyProc3()
RPCCall(<name, MyProc_3);
end.
And that would be possible, albeit awkward / ugly. But what about such situations?
RPCcall
//business logic
if conditionA then begin
if conditionA2 then begin
RPCCall
//business logic
end else
RPCCall
//business logic
end else begin
for i=1 to 10 do begin
RPCCall
//business logic
end;
end
end
I do not see realistically how to transform the above continuation style. If there is a call in the middle of a logical tree or loop, how can I return to this state? How was this done before? Incorrectly transcode an outdated application. It is very large and complex.
Any help would be appreciated. Thanks