Sample Programs

Cobolscript programs can be executed via a Command Prompt, Device Browser, Telnet/SSH session, or Xterm by simply invoking the interpreter (cobolscript.exe on Windows or cobolscript on Unix) followed by the name of the program to execute ).

Command Prompt

Device Browser

Telnet/SSH Session

Xterm

Below are example programs that demonstrate the use of various Commands and Functions available in the cobolscript programming language.

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.

COPYBOOK_CPY

Example COPYBOOK

COPYBOOK_INC

Example COPYBOOK

count_cbl

Return number of emails in an email account.

datafile_txt

Data file for source code examples.

dep_cbl

Generic depreciation example

display_cbl

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

dns_cbl

Domain Name Service query example.

down_cbl

File download example.

Binary file for the File Download example source code to use.

dynfile_cbl

Dynamic file creation example.

email_cbl

Send/Receive email examples.

eprb_cbl

CGI example.

execute_cbl

How to use the EXECUTE command to dynamically execute statements.

financefuncs_cbl

Financial calculation and depreciation functions.

ftp_cbl

File Transfer Protocol commands.

f_exec_cbl

A file processing example that uses the EXECUTE command.

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.

getcmdline_cbl

(New Ver 4.0 feature)

Retrieve command line arguments.

getenv_cbl

How to retrieve environmental variables from the operating system.

gethn_cbl

Use of GETHOSTNAME command.

gettime_cbl

Use of GETTIMEFROMSERVER command.

gm_cbl

Get email example source code.

goback_cbl

How to terminate a program using GOBACK.

hello.cbl

Hello World example basic.

hello1_cbl

Hellow World example #1

hello2_cbl

Hello World example #2

hello3_cbl

Hello World example #3

hmathfuncs_cbl

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

if_cbl

IF conditions.

init_cbl

How to initialize variables.

input_cbl

Input data file for RECCOPY.CBL sample program.

input_csv

Data file for input.cbl source coce example.

IO_DAT

Data file for source code example.

lower_cbl

(New Ver 4.0 feature)

Lowercase example.

ltrim_cbl

(New Ver 4.0 feature)

Left Trim example.

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.

oper_cbl

Examples of operator usage.

OUTPUT_DAT

Output file from example source code program.

PAGE_CBL

Simple CGI example.

perform_cbl

Use of the PERFORM command.

pic_cbl

Picture clause example usage.

position_cbl

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

prb_cbl

Example CGI source code.

PRB_TXT

Data file for CGI example prb.cbl

probfuncs_cbl

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

profoccr_cbl

Professional Edition OCCURS clause example.

rb_cbl

rb.cbl

(New Ver 4.0 feature)

Reading Blocks of text.

read_cbl

How to read data from files.

reccopy_cbl

Read and Write file example.

replica_cbl

How to use the REPLICA clause.

rewrite_cbl

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

rtrim_cbl

(New Ver 4.0 feature)

Right Trim example.

serv_cbl

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

set_cbl

Example of SET statement.

shm1_cbl

(New Ver 4.0 feature)

Shared Memory programming example 1.

shm2_cbl

(New Ver 4.0 feature)

Shared Memory programming example 2.

size_cbl

Determine size in bytes of an email.

sm_cbl

Send email example.

sprb_cbl

CGI web example.

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.

test_dat

Data file for example program.

timesht_txt

Data file for uts.cbl CGI example program.

tok_cbl

(New Ver 4.0 feature)

String tokenizing example.

trim_cbl

(New Ver 4.0 feature)

String trim example.

upper_cbl

(New Ver 4.0 feature)

Upper Case conversion example.

uts_cbl

CGI example source code.

vprb_cbl

CGI example source code.

web_cbl

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

web_cbl

Data file created by web.cbl source code example.

webban.cbl

CGI example to display a banner in text.

write_cbl

How to write data to a file.

WRITE1_DAT

write.cbl data file.

write2_dat

write.cbl data file.