The
Rocket COBOL extension supports COBOL notebooks, which have the file extension
.cblnb. COBOL notebooks enable you to write executable COBOL code cells and Markdown cells in one document. Notebooks can compile
either as native COBOL or as
.NET COBOL code. You can configure certain settings to apply to individual cells or to the notebook as a whole.
Note: The COBOL Language Server features are available to use within COBOL notebooks if you have a licensed
Visual COBOL or Enterprise Developer product release 9.0 or later installed on your machine
Create a COBOL notebook
In
Visual Studio Code:
- Click
.
- Select
New COBOL Notebook from the drop-down list of file types. If it is not listed, type
COBOL Notebook. Alternatively, in the
EXPLORER view, click
New File
to create a new file. When naming the file, add the
.cblnb extension and the editor will change accordingly to show the layout for a blank COBOL notebook.
Add code and Markdown cells
To add a cell to a COBOL notebook:
- Click
Add Code Cell
at the top-left of the notebook or in the center of the editor to add a COBOL code cell.
- Click
Add Markdown Cell
at the top-left of the notebook or in the center of the editor to add a Markdown cell.
The cell type is labelled in the bottom right corner of each cell. Markdown cells are blank, whereas code cells contain the
four division lines characteristic of COBOL programs.
Editing cells
- To edit a code cell, click anywhere in the cell, and begin typing.
- To edit a Markdown cell, double-click the cell or press enter.
If you have a licensed
Visual COBOL or Enterprise Developer product release 9.0 or later, you will have access to the following COBOL Language Server functionality
within notebooks:
- Context-aware code completion
- Hover pop-ups for data items
- Collapsible regions in code cells
- Error highlighting and reporting
- Rename Symbol
- Go to/Find/Peek definition and references
Run code cells
There are multiple ways to execute a cell. You have the option of running all cells within a notebook or running individual
cells.
- Click
Run
to run to the left of a code cell to run it.
- Click
Run All
in the notebook toolbar to run all cells in a notebook.
The output of a code cell is shown directly below the cell.
COBOL notebooks can compile native and
.NET COBOL. By default, the code type is set to native. To change to
.NET COBOL:
- Click
Cell type for run/debug
at the bottom of an individual code cell, or click
Cell type for run/debug
in the notebook toolbar to set all code cells.
This opens the drop-down list at the top of the editor.
- Select
.NET code from the drop-down list.
- Run the cell(s).
Debug code cells
Note: You need to run a cell before you can debug it.
Debugging a COBOL notebook follows the same procedures as debugging a COBOL program in
Visual Studio Code. For more information on debugging, see the
Debugging section.
- Set any breakpoint(s) in a code cell by clicking to the left of the line number.
- Click
to the left of the cell to start debugging.
This opens the Debug widget, which enables you to step into and through your code.
- In the Activity bar, click
Run and Debug
to open the
Run and Debug view. The breakpoint information is visible in the
Breakpoints panel.
- Step through the code using the Debug widget.
Other options
You can manipulate cells by clicking
More Actions
in the top right corner of a cell. Additional commands available for COBOL notebooks include:
- - add command line arguments in the
Add Command Line Argument box. If you select the
Edit Cell Command Line Arguments option again you can delete the previously specified argument(s).
- - provide a value for ACCEPT statements in the
Add ACCEPT Value box. If you select the
Edit Cell ACCEPT Values option again you can delete the previously specified value.
- Provide Input to Cell - click
Provide Input to Cell
if you are required to enter a value when running a code cell, and type the value in the
Provide Input box. Use this as an alternative to the
Add ACCEPT Value option.
Restrictions
- COPY statements do not resolve copybooks in a workspace.
- The
Debug Cell or
Step into Cell commands might not work if the cell has not been run first. You can also manually select
Notebook: COBOL Notebook Kernel from the Task Picker (Ctrl+Shift+P) to enable debugging.
- Output is displayed in the debugger output window when debugging rather than in the notebook itself.