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.
How to get the system date and time, and how to capture standard input.
Basic arithmetic commands (ADD, SUBTRACT, MULTIPLY, DIVIDE.
How to display a Unix-style banner.
How to display a calendar for a given month and year.
How to call an external application.
TCP/IP client example . use with SERV.CBL.
Different forms and uses of the COMPUTE statement, and the use of expressions.
Metric system to English system and English to metric conversion functions.
How to include copybooks with the COPY command.
Example COPYBOOK
Example COPYBOOK
Return number of emails in an email account.
Data file for source code examples.
Generic depreciation example
How to display different forms of output to the standard output device.
Domain Name Service query example.
Dynamic file creation example.
Send/Receive email examples.
CGI example.
How to use the EXECUTE command to dynamically execute statements.
Financial calculation and depreciation functions.
File Transfer Protocol commands.
A file processing example that uses the EXECUTE command.
Trigonometric functions (sine, cosine, inverses, hyperbolics, etc).
How to save a Unix-style banner to a variable.
How to save a calendar for a given month and year to a variable.
(New Ver 4.0 feature)
Retrieve command line arguments.
How to retrieve environmental variables from the operating system.
Use of GETHOSTNAME command.
Use of GETTIMEFROMSERVER command.
Get email example source code.
How to terminate a program using GOBACK.
Higher math functions (logs, natural logs, rounding, roots, etc).
IF conditions.
How to use the OCCURS clause.
How to open and close files.
Examples of operator usage.
Output file from example source code program.
Picture clause example usage.
How to use the POSITION statement to position to a particular record in a text data file.
Probability functions (random number generator, factorials, etc).
Professional Edition OCCURS clause example.
rb.cbl
(New Ver 4.0 feature)Reading Blocks of text.
How to read data from files.
Read and Write file example.
How to use the REPLICA clause.
How to use the REWRITE statement to update records in a text data file.
(New Ver 4.0 feature)
Right Trim example.
SQL return variable copybook.
How to terminate a program using STOP RUN.
Data file for uts.cbl CGI example program.
(New Ver 4.0 feature)
String tokenizing example.
CGI example to display a banner in text.
How to write data to a file.