In the previous section, we looked at an overview of VCSSL and Vnano.
Now, let's actually try writing and running a program, and performing some basic input and output.
As is customary in almost every language, let's start with a simple "Hello, World!" program:
print("Hello, World!");
HelloWorld.vcssl
It's not required, but you can also specify the character encoding on the first line, like this:
coding UTF-8; // Must be at the very beginning of the first line if used
print("Hello, World!");
HelloWorldCoding.vcssl
The above code runs in both VCSSL and Vnano. To run it as VCSSL, save the file with a ".vcssl" extension. For Vnano, use the ".vnano" extension. In either case, it's just a plain text file.
There are several ways to execute the code. Choose whichever method you prefer:
The most basic way is to use the official runtime environment, the VCSSL Runtime.
Download and launch the VCSSL Runtime from the link above, then select the file you saved (VCSSL or Vnano). It will run immediately.
When executed, a black window called the "VCSSL Console" will appear, like the one shown below. Any output from print() or similar functions will appear in this console:
While the console is open, you can press F11, or select "Reset (F11)" from the menu bar, to reload and re-run the current code.
So during programming, it's efficient to **keep the VCSSL Console open**, and work in a "write code in your text editor → hit F11 in the console to run" style.
You can also run VCSSL from the command line using the "vcssl" command by adding it to your system's Path environment variable.
VCSSL programs can also be run in the calculator software **RINEARN Processor**. In fact, as mentioned earlier, VCSSL was originally created for this very purpose.
Download and launch RINEARN Processor from the link above, enter the code into the "INPUT" field on screen, and press the "=" button (or just hit F11) to run it.
You can also define functions in VCSSL and use them directly in calculator expressions. Or you can place VCSSL scripts into a designated folder and call them up from the "Programs" menu.
In short, if you want to use VCSSL casually in your daily routine, this tool offers some nice conveniences.
That said, writing long blocks of code in a calculator's input field isn't exactly ideal -- frankly, it's a bit painful. For proper coding work, it's much more comfortable to use a normal text editor with the VCSSL Runtime.
RINPn is a smaller, lightweight calculator app, sort of a slimmed-down version of RINEARN Processor. It doesn't support full VCSSL code, but it can run Vnano scripts.
Download and launch RINPn from the link above. Click the Script button on the screen and select your Vnano code to run it.
Alternatively, you can also paste the file path of your code into the input field and press Enter, which is convenient if you're editing and re-running the script frequently.
Just like with RINEARN Processor, you can also define functions or variables in Vnano and use them in your calculator expressions.
Also, by adding rinpn to your system's "Path" environment variable, you can run code directly from the command line as well.
How did it go? Were you able to run your saved code successfully?
Before jumping into a detailed syntax breakdown, let's go over some commonly used basic input/output functions.
Use the "print()" function (no newline) or println() (with newline) to display messages in the console:
println(123); // Use print() instead if you don't want a newline
println("Hello");
Println.vcssl
This will output "123" and "Hello" on separate lines.
You can also pass multiple arguments to print() or println(), and they'll be printed with spaces between them. If you pass an array, its elements will also be printed with spaces in between.
To manually insert newlines, use the newline constant "EOL":
print("aaa" + EOL + "bbb" + EOL + "ccc");
Print.vcssl
To get user input -- whether it's a string, number, or something else -- you can use the input() function:
int a = input("Please enter an integer");
print(a);
Input.vcssl
The return value of input() is a string, but it will automatically convert to the appropriate type when assigned. If the conversion fails, you'll get a runtime error.
VCSSL is statically typed, but it allows some flexibility in small-scale use cases like this.
If you want to check whether a value can be converted to a number, you can use functions like isInt(string) or isFloat(string) after importing the relevant modules:
import system.Int;
import system.Float;
bool isInt = isInt("123"); // returns true
bool isFloat = isFloat("12.34"); // returns true
IsInt.vcssl
There are also functions like confirm() for yes/no prompts, and choose() for selecting files:
if( confirm("Would you like to select a file?") ) {
string filePath = choose("Please select a file", "./");
print("Selected file = " + filePath);
}
Confirm.vcssl
In the next section, we'll go over the basic syntax of VCSSL.