Skip to content
Find file History
..
Failed to load latest commit information.
README.md
hello.cob
run.js

README.md

Hello Asynchronous Sample

The clasical program, using perform ... async [with error] and display verbs.

Setup

Install Node.js.

Run

With the command line:

node run hello.cob

The output:

Hello, World

hello.cob code:

procedure division.
perform sayhello async.
local name.
perform getname async giving name.
display name.

sayhello async.
display "Hello, " with no advancing.

getname asynchronous.
return "World".

Usually a perform code like this:

procedure division.
perform sayhello.
display "World".

sayhello.
display "Hello, " with no advancing.

is compiled to:

sayhello();
runtime.display("World");
function sayhello() {
   runtime.write("Hello ");
}

Instead a perform async code:

procedure division.
perform sayhello async.
display "World".

sayhello async.
display "Hello, " with no advancing.

is compiled using callbacks to:

sayhello($cb1);
function $cb1() {
    runtime.display("World ");
}
function sayhello($cb) {
    runtime.write("Hello ");
    $cb();
}

You MUST use async in both places: at perform invocation and procedure declaration.

Something went wrong with that request. Please try again.