This sample is a native console application that demonstrates a simple command line application wrapping a legacy program which can maintain a book repository using conventional COBOL file IO.
This sample is targeted towards development and debugging in Visual Studio Code. This can be run on both Windows or Linux locally or remotely using Microsoft's remote development extensions for vscode.
The sample is structured as follows:
.editorconfig- Configuration file containing source formatting options.bld.bat- Windows build script for building the sample.Makefile- Linux makefile for building the sample.directives.mf- Contains COBOL compiler directives required for building the sample.src/book.cbl- The business logic for the book repository.src/cli.cbl- Entry program that accepts a command line and calls book.cpy/book-rec.cpy- Copybook shared between programs.obj/- Directory where object and debug files get written.bin/- Directory where the application binary is written to..vscode/tasks.json- Configuration for building the sample within vscode..vscode/launch.json- Configuration for running and debugging the sample within vscode.add-books.bat- Windows batch script that adds sample data to the book repository.add-books.sh- Unix shell script that adds sample data to the book repository.
- Open the folder in Visual Studio Code.
- Press F5, or Run -> Start Debugging to run the application.
- You can debug the code by inserting a breakpoint and running the application.
- To add a set of sample books, open a Rocket® Visual COBOL® terminal and run
.\add-books.bat(Windows) or./add-books.sh(Linux).
- Open a Visual COBOL or Enterprise Developer prompt.
- Navigate to the root directory for this sample.
- Execute
bld.batto build the sample. - Execute
bin\book.exeto run the sample. - Execute
.\add-books.batto add some sample data to the book repository.
-
Setup a devhub environment. Typically this would be done as follows:
. /opt/microfocus/VisualCOBOL/bin/cobsetenv -
Navigate to the root directory for this sample.
-
Execute
maketo build the sample. -
Execute
bin/bookto run the sample. -
Execute
./add-books.shto add some sample data to the book repository.
Below are some exercises that you are welcome to follow that can help you become more familiar with the Rocket® Visual COBOL® tooling and language.
- Fix a bug that prevents the
-foption from working correctly. - Display the genre of the books when executing the
listcommand. - Refactor shared data items and constants between cli and book (e.g.
ws-function, andws-file-status) to a copybook that is included by both programs. - Refactor the sample to use local variables and parameterised sections.
Copyright 2023-2025 Rocket Software, Inc. or its affiliates. This software may be used, modified, and distributed (provided this notice is included without modification) solely for internal demonstration purposes with other Rocket® products, and is otherwise subject to the EULA at https://www.rocketsoftware.com/company/trust/agreements.
THIS SOFTWARE IS PROVIDED "AS IS" AND ALL IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, SHALL NOT APPLY. TO THE EXTENT PERMITTED BY LAW, IN NO EVENT WILL ROCKET SOFTWARE HAVE ANY LIABILITY WHATSOEVER IN CONNECTION WITH THIS SOFTWARE.