InterSystems ObjectScript is a programming language that is used in InterSystems databases such as InterSystems IRIS and Caché. Visual Studio Code (VSCode) is a popular text editor that can be used to write and edit ObjectScript code.
- Install InterSystems Extensions
- Set ObjectScript Color Theme
- Connect to a Server
- Store Credentials
- Open a Namespace
- Writing ObjectScript Code
- Use SQLTools
Go to the Activity Bar on the far left-hand side and click on the Extensions
tap.
Type in the search bar InterSystems and then install the InterSystems ObjectScript Extension Pack . This Extension pack includes:
- InterSystems ObjectScript: Adds InterSystems ObjectScript language support.
- InterSystems Language Server: Adds InterSystems ObjectScript language server.
- InterSystems Server Manager: Define connections to InterSystems servers. Browse and manage those servers.
To provide correct color highlighting when working with Objectscript choose a InterSystems Color Theme.
- Navigate to
File > Preferences > Color Theme
- Choose
InterSystems Default Dark
orInterSystems Default Light
.
-
You can see default configuartions under
All Servers
-
If you want to create a new Server connection click on the
+
button in the top and then fill in the connection properties:- Name of new server definition: Give your Connection a name.
- Optional Description: A optional description for your server. Tap
Enter
to leave empty. - Hostname or IP address of web server: The Hostname or IP Address of your server.
- Port of web server: The Port of the web server.
- Username: The Username of your Iris user you want to connect from.
- Confirm connection type: http or https connection type.
After successfully adding a new Server you can see the Server under All Servers
.
Tip: You can edit your Server Properties under:
...
in the top right corner> Edit Settings > InterSystems: Servers > Edit in settings.json
.
Everytime you close Visual Studio Code and reopen it, it will prompt you a message to log in with your credentials. To avoid this you can store your credentials:
- Store Username:
- In the Command Palette type Preferences: Open User Settings (JSON). Here you can see your server connection in a JSON format.
- Choose the server you want to add your username and add a property called username
Example:
"default~iris": {
"webServer": {
...
},
"username":"<your-username>",
"description": "Connection to local InterSystems IRIS™ installed with default settings."
}
- Store password
- Next time you open Visual Studio code, it will prompt you a dialog and ask for a password
- Type in your password
- Click on the key button in the top right corner of the dialog to store the password
- Delete password
- Navigate to Accounts in the Activity Bar
- Select your user
- Click on
Sign Out
- select
Delete
when asked to delete password
- Open the
InterSystems Tools
tap in the Activity Bar. - Choose a Server and click on it.
- If the connection is succesfully you will see a new directory named Namespaces.
- If the connection failed you will see Unavailable at <current-time>.
- Choose a namespace.
- Click on the eye-icon next to your namespace to view the namespace in your workspace.
- Click on the pen-icon next to your namespace to edit the namespace in your workspace.
- Open the
Explorer
tap in the Activity Bar. - Do a right-click and choose
Add Server Namespace to Workspace
. - Now choose your Server or create a new one with the
+
in the top right corner of the dialog. - Choose a Namespace.
Once you have connected to a Namespace, you can begin writing ObjectScript code. Here are the basic steps for doing so:
- Create a new file with the
.cls
file extension (for example,MyPackage.MyClass.cls
) - Write your ObjectScript code in this file.
- The class will be compiled after you saved the file.
You can also create other files with the extension .mac, .inc etc.
When you want to have a look inside your database without leaving Visual Studio Code, you can use the SQLTools extension.
- Install the SQLTools extension
- Install the SQLTools InterSystems IRIS
- Navigate to the SQLTools tap in the Activity Bar and choose
Add New Connection
- Choose InterSystems IRIS and fill out the connection properties
- Choose
Connect Now
and you will see a new connection under Connections - Now you can create a new SQl file and run the Query on your connection with
Run on active connection
OR - Browse through your tables and views, by unfolding the connection, and then view the table or view by clicking on the magnifyingglasses icon.
by Philipp B.