A common scenario for when you can use Visual Studio Code with the Rocket COBOL extension is if you want to make quick edits to your COBOL applications running on a remote machine.
The following demonstration shows how you can use Visual Studio Code with the Rocket COBOL extension from a local machine to edit, compile, and debug a COBOL application that runs on a remote Linux machine. On your local machine you do not need to have any Rocket Software products installed nor to have the COBOL sources.
An existing Microsoft technology enables you to connect your local Visual Studio Code to remote machine using SSH. It initializes a Visual Studio Code server on the remote machine that has direct access the COBOL sources stored on the remote machine while managing them from the local Visual Studio Code interface.
First, you need to prepare your local machine. You need to install Visual Studio Code and set it up to connect to the remote Linux machine.
Note that you do not need any Rocket Software products on your local machine nor your COBOL sources.
On your remote Linux machine, you need the following:
For this demonstration, we are going to use the tictac sample available with the installed Rocket Software products. In real life scenarios, the executable files will be stored on the remote machine so you do not need to compile your code. In this demonstration, you are going to see how you can compile as well.
Copy the tictac.cbl file from its original install location to a working directory on the remote machine. You are going to need a script file that includes the command to compile the source code:
cob -xg -C errformat=3 tictac.cblWhere errformat=3 sets the ERRFORMAT Compiler directive for when you are building the source code. You need to compile with this directive in order to get the error information to include in Visual Studio Code with a Problem Matcher.
chmod +x ./build.sh
Because the tictac application uses character screens for Input and Output, you also need to ensure that the information can appear in an X terminal. Follow the instructions in the Debugging Using the Remote Development Extensions topic.
This button is provided by the Remote extension pack. You can check the status that it displays to know whether the particular Visual Studio Code instance you are looking at is running on the local or the remote machine.
This starts a new instance of Visual Studio Code.
Visual Studio Code installs Visual Studio Code server on the remote machine. Note that the status next to the button shows the IP address of the remote machine.
You are now running a local instance of Visual Studio Code that is connected to the remote machine and can access its file system and the Rocket Software COBOL environment on it. There are no Rocket Software products installed locally.
This opens the
Open Folder widget. This is showing a UNIX-style path which confirms you are connected to the remote machine.
This now shows the files in the folder that contains the tictac example.
Note that the editor does not show any colorization yet. This is because you do not have the Rocket COBOL extension installed yet.
You are now going to install Rocket COBOL in the Visual Studio Code server instance running on the remote machine:
Alternatively, you can install it from a .vsix file saved to your local machine.
Visual Studio Code shows a notification once the installation has completed. It also shows a notification that you need to install Visual COBOL or Enterprise Developer in order to enable compiling and debugging. In the next section, you are going to configure the extension to use the Rocket Software COBOL product which is already installed on the remote machine.
The COBOL source opened in the editor from the remote machine is now colorized which means the editing support provided by Rocket COBOL is now available.
In order to be able to compile and debug your COBOL sources, you need to specify the location of a licensed Rocket Software product in the extension. As the extension is installed on the remote machine thanks to Visual Studio Code server and the Remote-SSH extension, you can specify the location to the Rocket Software product already available on the remote machine:
The default install locations are /opt/microfocus/EnterpriseDeveloper and /opt/microfocus/VisualCOBOL, respectively, but your product might be installed in a different location.
Visual Studio Code uses build tasks to compile source code. You created the build.sh script that includes the necessary compile instructions so you need to integrate this file into a build task:
As there are no predefined tasks, the selection widget provides an option for configuring one.
This creates a default tasks.json file in a .vscode subdirectory in the working directory on the remote machine where your tictac program is stored.
{ "label": "cobol", "type": "COBOL-shell", "command": "./build.sh", "problemMatcher": ["$COBOLErrFormat3"], "group": "build" }
This triggers a build. Check the Terminal panel to see if it has completed and if there were any issues with it.
The executable and debuggable files have been created as well and are visible in the working directory - tictac, tictac.idy, tictac.int, and tictac.o.
You are now ready to debug your application:
This creates a template launch.json file with two default debug configurations in the .vscode subdirectory. You are going to use the one that launches the application - the one that has "name": "COBOL (native): Launch". You need to change this configuration to launch the tictac executable.
"program": "${workspaceFolder}/<insert-program-name-here>",
With:
"program": "${workspaceFolder}/tictac",
Visual Studio Code enters debug mode and the cursor is positioned on the first executable statement in your COBOL program.