Edit Code Locally on Your Client Machine
This page describes how to edit code locally on your client machine using Visual Studio Code (VS Code) and then deploy that code on your InterSystems® server. It assumes that you have already defined a connection profile for your server using the InterSystems Server Manager extension for VS Code and that you have opened a local workspace for client-side editing.
Connect a Server to a Client-Side Workspace describes how to initialize the connection between your local workspace folder and your InterSystems server using the InterSystems ObjectScript extension for VS Code. Once you have established a connection, you can export, edit, import and compile code as described in subsequent sections.
For instructions on how to test and debug your code using the InterSystems ObjectScript Extension Pack for VS Code, refer to the Develop ObjectScript Unit Tests page and the Run and Debug Your ObjectScript Code page, respectively.
Connect a Server to a Client-Side Workspace
To establish a connection between a server and a client-side workspace, perform the following steps:
-
Open the folder where you want to store your client-side files.
-
Navigate to the InterSystems view container by selecting the InterSystems button in the Activity Bar.
-
Select the Choose Server and Namespace button within the ObjectScript Explorer view or the InterSystems Projects Explorer view. (See Work with Projects for more information about projects.)
-
Use the menu to select an server from the list of existing InterSystems server connection profiles. Type + to add a new server connection profile.
-
Follow the prompts to sign into a server and select a namespace.
Alternatively, you can connect a client-side workspace to a server by invoking the ObjectScript: Connect Folder to Server Namespace command from the Command Palette and following the prompts provided.
This procedure creates a /.vscode/settings.json file in your workspace’s root-level folder (if it does not already exist), and appends an objectscript.conn object to this settings file for the server and namespace you have selected. The next time you open this workspace, VS Code will attempt to reconnect to this server and namespace. This procedure also adds the server and namespace to the status bar.
Editing the settings.json File
When you connect a server to a client-side workspace using the ObjectScript extension creates a /.vscode/settings.json file (if it does not already exist) and appends an objectscript.conn object to this settings file which describes this connection. In a simple case where a workspace is connected to a single InterSystems server, the settings.json file may look like this:
{
"objectscript.conn": {
"server": "iris",
"ns": "USER",
"active": true
}
}
In most cases, it is sufficient to allow the InterSystems ObjectScript extensions for VS Code to manage connections between your workspace and your InterSystems servers, and there is no need to modify this file.
In some cases, however, further configuration may be necessary. For example, if you need ObjectScript compilation flags other than the default ones, add an objectscript.compileFlags property to settings.json:
{
"objectscript.conn": {
"server": "iris",
"ns": "USER",
"active": true,
},
"objectscript.compileFlags": "cuk/compileembedded=1"
}
You can find more information about objectscript.compileFlags and other available settings on the Settings Reference page.
Export Code from the Server
To perform client-side edits to source code that exists on the server, export copies of source code files to your client-side workspace by performing the following steps:
-
If you have not already done so, open a local folder to serve as your current workspace and connect it to your InterSystems server.
-
Navigate to the InterSystems view container by selecting the InterSystems button in the Activity Bar.
-
Within the ObjectScript Explorer view, locate and select the document or documents that you want to export from the server.
-
Right-click on your selection and select Export from the context menu.
Alternatively, you can export files by issuing the ObjectScript: Export Code from Server command from the Command Palette, and then selecting the desired files from the menu.
By default, the export command copies files into a /src/ subfolder within your workspace’s root folder. You can change this using the objectscript.export.folder setting. Refer to the InterSystems ObjectScript section of the Settings Reference for information about this and other settings which configure the behavior of the export command.
Import Code to the Server
By default, when you save code in a client-side workspace that is connected to an InterSystems server, the ObjectScript extension automatically imports and compiles that code onto the connected server. You can change this behavior by modifying the objectscript.importOnSave and objectscript.compileOnSave settings.
When it is necessary to import code manually from a client-side workspace to a connected InterSystems server, you can do so by performing the following steps:
-
If you have not already done so, connect your workspace to the InterSystems server where you want to import your code.
-
Navigate to the Explorer view container by selecting the Explorer button in the Activity Bar.
-
Right-click on the file or folder which contains the code you want to import to access the context menu.
-
Select one of the following options from the context menu:
-
Import and Compile — Imports the code onto the server and then attempts to compile it.
-
Import Without Compilation — Imports the code onto the server, but does not attempt to compile it.
-