Skip to content

Lab 01 - VoltScript simple program

Duration 10 min

What you will learn

You'll learn how to use the Visual Studio Code extension to compile and run basic scripts.

Prerequisites

  • Visual Studio Code installed
  • VoltScript Extension installed
  • VoltScript runtime executable and dependencies installed

Steps

The IDE

  1. Open Visual Studio Code.
  2. Bring up the Extensions view by using Ctrl + Shift + X or clicking the Extensions icon in the Activity Bar.
  3. Under Installed, select VoltScript Language Support.

    VoltScript Language Support

    Note

    The search bar allows you to search for an extension in the VS Code Marketplace and not in the folder of installed extensions. The "VoltScript Language Support" extension hasn't yet been published to the VS Code Marketplace.

  4. Return to the Explorer view, and click Open Folder.

    VoltScript Language Support

  5. Create a new folder in your user directory called "lab-01".

  6. Select the "lab-01" folder to open in VS Code.

helloworld.vss

  1. Click the New File icon above the empty pane for the folder. You can also right-click in the empty pane and select New File from the context menu.
  2. Name the file "helloworld.vss".

    Warning

    A notification will be received "An error was thrown while processing document" in the bottom right of VS Code. This is normal. The file has been identified as a VoltScript file, but cannot be parsed by the language support at this time.

    Info

    Note the information at the right side in the status bar at the bottom of VS Code. The file is automatically identified as UTF-8, CRLF is used as the line ending, and the language has been identified as "VoltScript". To ensure compatibility with Linux, you should change line endings to LF.

  3. Type Print "Hello World".

    Info

    The language support extension doesn't contribute content assist (typehead) or formatting at this time. However, VoltScript code is compiled as you type. Errors are underlined in red and hovering will provide the compilation error. You can also find them in the Problems view by going to ViewProblems, or pressing Ctrl+Shift+M.

  4. Press Ctrl+Shift+P or select ViewCommand Palette.

  5. Start typing "VoltScript" to filter for VoltScript commands. Select "VoltScript: Save & Run Script".

    Success

    A "VoltScript" terminal will be created and Hello World will be printed there.

    Tip

    VoltScript code doesn't have to be in a Sub. However, some language features, such as Try...Catch, can only be used within a sub or function. It's best practice to put all your code in a Sub Initialize method as LotusScript developers will be familiar with from Agents in Domino Designer. Option settings can also be added, as in Domino Designer, such as Option Declare or its alias, Option Explicit and Option Public. These can't be added automatically and there aren't currently snippets for this.

    Warning

    If you use a Sub Initialize, ensure you spell Initialize correctly. If not, it will just be ignored and the sub won't be run.

How to check

Print to console:

Hello World
[Info - XX:XX:XX AM] Script finished

The completed lab is available on GitHub.

Things to explore

  • Put your code in Sub Initialize and run it.
  • Add Option settings.
  • Try alternate string delimiters {} and ||. Note syntax highlighting is as expected.
  • Try other language functions. MsgBox has become an alias to Print. As there is no UI and as VoltScript is intended for server-side processing only, so MsgBox makes no sense. Similarly, InputBox() is unsupported.

Next step

Proceed to Lab 02 - VoltScript Project with VoltScript Library Module.