About Sample Programs

Sample CobolScript® Programs

Each of the sample programs listed below demonstrates a particular command, feature, group of features, or syntax of the CobolScript language. These samples can be used as instructional tools, or as templates for development.

Working with data files requires the proper read and write permissions on directories and files. On Unix systems especially, attempting to run a file manipulation program with insufficient file or directory privileges is a common oversight. Failing to set these permissions correctly will prevent CobolScript file input and output. Make certain that permissions are set correctly before manipulating files with a CobolScript program.

All sample programs are available for download from the Deskware Registered User web site. Refer to your license agreement for information on restrictions governing the redistribution of these programs, or of programs based on these programs.

Command Line Sample Programs

The following sample programs can be run from the command line. To run one of them, at the command prompt type:

cobolscript.exe <program-name>

where <program-name> is the name of the sample program to be run.



Program Name

Demonstrates…

ACCEPT.CBL

How to get the system date and time, and how to capture standard input.

ARITHMETIC.CBL

Basic arithmetic commands (ADD, SUBTRACT, MULTIPLY, DIVIDE.

BANNER. CBL

How to display a Unix-style banner.

CAL.CBL

How to display a calendar for a given month and year.

CALL.CBL

How to call an external application.

CLIENT.CBL

TCP/IP client example – use with SERV.CBL.

COMPUTE.CBL

Different forms and uses of the COMPUTE statement, and the use of expressions.

CONVFUNCS.CBL

Metric system to English system and English to metric conversion functions.

COPY.CBL

How to include copybooks with the COPY command.

DISPLAY.CBL

How to display different forms of output to the standard output device.

DYNFILE.CBL

Dynamic file creation example.

EXECUTE.CBL

How to use the EXECUTE command to dynamically execute statements.

F_EXEC.CBL

A file processing example that uses the EXECUTE command.

FINANCEFUNCS.CBL

Financial calculation and depreciation functions.

FTP.CBL

File Transfer Protocol commands.

GEOMFUNCS.CBL

Trigonometric functions (sine, cosine, inverses, hyperbolics, etc).

GETBAN.CBL

How to save a Unix-style banner to a variable.

GETCAL.CBL

How to save a calendar for a given month and year to a variable.

GETENV.CBL

How to retrieve environmental variables from the operating system.

GETHN.CBL

Use of GETHOSTNAME command.

GETTIME.CBL

Use of GETTIMEFROMSERVER command.

GOBACK. CBL

How to terminate a program using GOBACK.

HMATHFUNCS.CBL

Higher math functions (logs, natural logs, rounding, roots, etc).

IF.CBL

IF conditions.

INIT.CBL

How to initialize variables.

INPUT.CSV

Input data file for RECCOPY.CBL sample program.

MAIL.CBL

How to send simple emails, retrieve emails, and get count of emails on an SMTP server.

MOVE.CBL

Use of the MOVE statement.

OCCURS.CBL

How to use the OCCURS clause.

OPENCLSE.CBL

How to open and close files.

PERFORM.CBL

Use of the PERFORM statement.

POSITION.CBL

How to use the POSITION statement to position to a particular record in a text data file.

PROBFUNCS.CBL

Probability functions (random number generator, factorials, etc).

PROFOCCR.CBL

Professional Edition OCCURS clause example.

RECCOPY.CBL

A command-line program that demonstrates how to convert delimited files that were created in Excel or other applications to CobolScript delimited files, if record updates are necessary to the data.

READ.CBL

How to read data from files.

REPLICA.CBL

How to use the REPLICA clause.

REWRITE.CBL

How to use the REWRITE statement to update records in a text data file.

SERV.CBL

TCP/IP server example – use with CLIENT.CBL.

SET.CBL

Use of SET statement.

SQL.CBL

Professional Edition SQL example.

SQL.CPY

SQL return variable copybook.

STOPRUN.CBL

How to terminate a program using STOP RUN.

TCPIP.CPY

TCP/IP return variable copybook.

WEB.CBL

How to retrieve web pages and save them to a file.

WRITE. CBL

How to write data to a file.



Web-Based Sample Programs

The following sample programs are meant to be executed from a web browser. A web server must be running on the machine on which CobolScript is installed, and CobolScript and the CobolScript programs must be placed in the web server's cgi-bin directory. On Unix machines, make certain that file and directory permissions allow reading and writing to the cgi-bin directory.

If the web server is running properly and all files are in the correct location, any of the programs below can be run by typing:

http://<ip address>/cgi-bin/cobolscript.exe?<filename>

in the web browser's URL, where <ip address> is the web server's IP address or domain name, and <filename> is the name of the program to be run.

Program Name

Demonstrates...

DEP.CBL

Depreciation calculator.

DNS.CBL

How to obtain information about IP addresses or domain names.

DOWN.CBL

How to construct a download MIME header and use DISPLAYFILE and DISPLAYASCIIFILE.

EMAIL.CBL

Web based form for sending email with CobolScript.

EPRB.CBL

Problem Tracking entry editing.

HELLO.CBL

`Hello world` program.

HELLO1.CBL

Chapter 5 CGI Sample #1.

HELLO2.CBL

Chapter 5 CGI Sample #2.

HELLO3.CBL

Chapter 5 CGI Sample #3.

INPUT.CBL

How to accept CGI data.

OPER.CBL

Mathematical operator example program.

PAGE.CBL

Chapter 7 Sample.

PIC.CBL

CobolScript Picture clause variation.

PRB.CBL

Problem Tracking system example application.

SPRB.CBL

Problem Tracking entry submission.

UTS.CBL

Time Sheet example application.

VPRB.CBL

Problem Tracking entry viewing.

WEBBAN.CBL

How to print a Unix-style banner to a web page.