Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
README.md
factorial.cobp
server.js

README.md

Template Web Sample

CobolScript code can be embedded in a text file, and it can be used to make a web page.

Setup

Install Node.js.

Run

With the command line:

node server

The output:

Server started, listening at port 8000

Then launch http://localhost:8000 in your browser. It works!

Factorial Web Sample

The template file is factorial.cobp (actually, .cobp extension is reserved to this kind of web pages with templates):

<h1>Factorial</h1>
<p>Page generated by CobolScript, using templates</p>
<table>
<tr><th align='right'>n</th><th align='right'>n!</th></tr>
<#
local n.
perform show-factorial using n varying n from 1 to 10.
#>
</table>
<#
.

show-factorial using n.
local result.
perform factorial using n giving result.
#>
<tr><td align='right'>${n}</td><td align='right'>${result}</td></tr>
<#
.

factorial using n.
local m.
if n = 1 then return n.
subtract 1 from n giving m.
perform factorial using m giving m.
multiply n by m.
return m.
#>

CobolScript code is embedded between <# and #>. CobolScript expressions are embedded between ${ and }.

Something went wrong with that request. Please try again.