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 runtime and VS Code Extensions installed.
Steps
The IDE
-
Create a new VS Code VoltScript Workspace folder called lab-01:
- Open Visual Studio Code.
-
From the Explorer view, click Open Folder.
-
Create a new folder in your user directory, with the name stated above.
- Select the newly created folder to open in VS Code.
helloworld.vss
- 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.
-
Name the file "helloworld.vss".
Warning
A notification might 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.
-
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 View → Problems, or pressing Ctrl+Shift+M.
-
Press Ctrl+Shift+P (Cmd+Shift+P on Mac), then select VoltScript: Save & Run Script. (You can start typing "VoltScript" to filter the available commands).
-
Press the
Enter
key to confirm your input (no script arguments are necessary).Success
A VoltScript terminal will open in your workspace and display the result of your script.
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. A best practice is to start your code within aSub Initialize
method; as LotusScript developers will be familiar with that pattern. In order to keep this lab as simple as possible that pattern was intentionally not followed.Options settings can also used, such as
Option Declare
orOption Public
. Unfortunately at this time Visual Studio Code cannot be configure to add these automatically.
How to check
Print to console:
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 toPrint
. As there is no UI and as VoltScript is intended for server-side processing only, soMsgBox
makes no sense. Similarly,InputBox()
is unsupported.
Next step
Proceed to Lab 02 - VoltScript Project with VoltScript Library Module.