This section introduces the most commonly used standard libraries provided by VCSSL.
Note that large-scale libraries such as GUI, Graphics2D, and Graphics3D are not covered here. Please refer to the separate guides for those:
Standard libraries are pre-installed and ready-to-use libraries available by default.
Ordinarily, using a library requires users to download it and place it in the same directory as the executable module or a system-defined location. However, standard libraries require no such setup -- they're always available and ready to use.
The role of standard libraries is to provide essential features commonly needed when developing real-world programs.
It would be inefficient if every user had to reimplement such basic functionality from scratch. Also, it would make reading someone else's code more difficult if everyone handled these basics differently. By providing them as standard libraries, consistency and convenience are both achieved.
Additionally, features that depend on the graphics system, GUI elements, the operating system, or the interpreter environment are also provided through standard libraries.
In fact, you've already been using a standard library this whole time -- through functions like "print", which display messages to the console.
These functions are provided by the standard library named "System". Try the following example:
import System ;
System.print( "Hello, World ! " ) ;
ImportSystem.vcssl
When you run this program, you'll see:
This confirms that the "print" function is provided by the System library.
In VCSSL, the System library is automatically imported before any user-defined modules are loaded, which is why you were able to use "print" and similar functions without importing anything.
Among standard libraries, only the System library can be used without an import statement. Since System provides fundamental functionality used in almost all cases, it's treated as an exception.
Other standard libraries must be explicitly imported like regular libraries. This avoids unnecessary loading of libraries you don't use -- which helps reduce startup time and prevents name conflicts.
As a rule of thumb, only import the libraries that your module actually uses, both for clarity during development and for runtime efficiency.
For a full reference of VCSSL's standard libraries, see:
Here is a list of the main standard libraries (note: additional libraries exist beyond this list):
Among these, the libraries you'll likely use most frequently (besides System) are: Math, Text, File, and Time.
Let's take a closer look at some of them.
The "Math" library provides basic mathematical functions and constants, such as "sin", "cos", and "PI".
Let's try using it:
import Math ; // Import the Math standard library
float value = sin( PI/2.0 ) ; // sin(pi/2), or sin(90 degree) = 1
print( value ) ;
MathSample.vcssl
Running this program will output:
The Math library also includes high-precision versions of many functions, which return varfloat values when needed.
The "Text" library provides basic string processing capabilities, such as searching and replacing text.
Let's see it in action:
import Text ; // Import the Text standard library
// Count the number of characters
int n = countText( "AAA/BBB/CCC" ) ;
println( n ) ; // Outputs: 11
// Extract substring from index 2 up to (but not including) index 5
string crop = cropText( "AAA/BBB/CCC", 2, 5 ) ;
println( crop ) ; // Outputs: A/B
// Find the first occurrence of "a/a"
int first = findText( "aaa/aaa/aaa", "a/a", FIRST ) ;
println( first ) ; // Outputs: 2
// Find the last occurrence of "a/a"
int last = findText( "aaa/aaa/aaa", "a/a", LAST ) ;
println( last ) ; // Outputs: 6
// Find all occurrences of "a/a"
int all[] = findText( "aaa/aaa/aaa", "a/a", ALL ) ;
println( all ) ; // Outputs: 2 6
// Find all matches of the regular expression "./."
int patternAll[] = findText( "AAA/BBB/CCC", "./.", ALL_PATTERN ) ;
println( patternAll ) ; // Outputs: 2 6
// Extract all substrings matching the regular expression "./."
string ext[] = extractText( "AAA/BBB/CCC", "./.", ALL_PATTERN ) ;
println( ext ) ; // Outputs: A/B B/C
// Replace all "a/a" with "@"
string repl = replaceText( "aaa/aaa/aaa", "a/a", "@", ALL ) ;
println( repl ) ; // Outputs: aa@a@aa
TextSample.vcssl
Each "println" result is shown as a comment on the corresponding line. As you can see, the Text library makes it easy to perform common string manipulations.
The File library provides functions related to file handling -- such as retrieving file paths and listing files.
Let's try it out with some examples:
import File ; // Import the standard File library
// Get the base path (location of the executable module)
string base = getFilePath( "." ) ;
println( base ) ; // Outputs the absolute path of the folder where the executable module is located
// Get the parent folder
string parent = getFilePath( ".." ) ;
println( parent ) ; // Outputs the absolute path of the parent folder of the module folder
// Get the absolute path of a specific file
string file = getFilePath( "test.txt" ) ;
println( file ) ; // Outputs the absolute path of test.txt located in the same folder as the module
// Convert a relative path to an absolute path
string rel = getFilePath( "./bbb/test.txt", "../aaa" ) ;
println( rel ) ; // Outputs the absolute path to bbb/test.txt, relative to the ../aaa folder from the module
FileSample.vcssl
The output of each operation is explained in the comments beside each "println()" statement.
As shown above, the File library allows you to retrieve various file-related information. You can use "/" as a directory separator, "." to refer to the current directory (base path), and ".." to refer to the parent directory.
The Time library provides functions for working with time and date information.
Here's an example of measuring elapsed time:
import Time ; // Import the standard Time library
// Get the current time
int start = time( ) ;
// Pause the program until the message is closed
alert( "Measuring time..." ) ;
// Get the time again
int end = time( ) ;
// Convert elapsed time (end - start) to seconds
int sec = second( end - start ) ;
// Display the elapsed time
print( sec ) ;
TimeSample1.vcssl
When you run this program, a message saying "Measuring time..." appears. After you close it, the time it took is displayed in seconds in the VCSSL console.
The "time()" function used above returns the elapsed time since the program started. The value is usually in milliseconds (1/1000th of a second), but the exact unit may vary depending on the environment.
To convert the result to a desired unit, VCSSL provides conversion functions such as:
Additionally, if you call functions like second(), minute(), or hour() without arguments, they return the current time (like a clock).
You can also use day(), month(), and year() to get the current date:
import Time ; // Import the standard Time library
// Display the current date as year/month/day
println( "Date = " + year( ) + "/" + month( ) + "/" + day( ) ) ;
// Display the current time as hour:minute:second
println( "Time = " + hour( ) + ":" + minute( ) + ":" + second( ) ) ;
TimeSample2.vcssl
When you run this code, it will display the current date and time.