System Functions and Constants
In this section, we will explore the "system functions" and "system constants", which are essential to understanding the foundational capabilities of VCSSL.
Sponsored Link
System Functions and Constants
"System functions" are functions provided by the system (interpreter) that processes VCSSL programs, unlike user-defined functions.
You've already used system functions multiple times in the content discussed so far. For example, the "print" function, which is used for outputting results, is a system function. In other words, you've been invoking functionalities of the VCSSL processing system to perform screen outputs.
Alongside these functions, the system also defines certain values, like the "maximum integer value that can be handled," as default constants.
System Functions/Constants Belong to the "System Library"
VCSSL allows for the grouping of multiple functions, variables, and more, into entities known as "libraries."
Some libraries, referred to as standard libraries, come bundled with the VCSSL processing system by default. The system functions/constants are grouped under one of these standard libraries: the "System" library.
Usually, to use a library, you need to specify that it should be loaded (using "import" or "include" declarations). However, since the "System" library is almost always needed, it is automatically loaded by default, requiring no additional action. That's why you've been able to use functions like "print" anytime.
For a detailed list of system functions/constants and their precise explanations, please refer to the following specification document:
Here, we'll provide brief introductions to some representative ones.
Representative System Functions
Below are some examples of representative system functions.
Function | Parameters (Arguments) |
Description |
---|---|---|
Args of any type and in any number | Displays the content of the arguments on the console. | |
println | Any type and in any number | Displays the content of the arguments on the console and adds a newline. |
output | Any type and in any number | Displays the arguments' content in the result display area, or behaves like the println function if such an area is absent. |
popup | Any type and in any number | Displays the content of the arguments in a popup window. |
input | Any type and in any number | Displays the content of the arguments in an input window and accepts input from the user. The last argument becomes the default input value. The input result is returned as a string type value. |
confirm | Any type and in any number | Displays the content of the arguments in an input window and accepts a YES/NO selection from the user. The selection result is returned as a boolean type value. |
select | Any type and in any number | Prompts the user to select one item from the arguments. The selection result is returned as a string type value. |
choose | Message: string | Prompts the user to choose a file or folder and returns the absolute path of the selected item as a string type value. The message argument specifies the message displayed in the selection dialog. An additional string argument can be passed to specify the location (folder) to choose the file. |
sleep | Stop time in milliseconds: int | Pauses program execution for the specified time. |
exit | None | Terminates program execution. |
hide ¦ | None | Makes the console invisible. |
show | None | Makes the console visible. |
clear | None | Clears the content of the console. However, clearing may not be possible depending on the processing system or settings. |
save | File path: string | Saves the current content of the console to the specified file. Adding another argument saves the value of that argument instead of the console content. |
load | None | Returns the current content of the console as a string value. Adding another argument and specifying a file path reads the content of that file instead of the console and returns it. |
re | Complex or varcomplex value | Returns the real part of the argument. The return type is float if the argument is complex value, and varfloat if it's varcomplex. |
im | Complex or varcomplex value | Returns the imaginary part of the argument. The return type is float if the argument is complex, and varfloat if it's varcomplex. |
Representative System Constants
Next, here are some examples of representative system constants.
Constant | Type | Description |
---|---|---|
INT_MAX | int | The maximum value of type int. |
INT_MIN | int | The minimum value of type int (maximum negative value). |
FLOAT_MAX | float | The maximum positive value for type float. Prepending a negative sign yields the maximum negative value. |
FLOAT_MIN_ABS_NORMAL | float | The smallest positive, non-zero absolute value representable in float type within the range of normalized numbers. Note that this is not the maximum value in the negative direction. |
FLOAT_MIN_ABS_DENORMAL | float | The smallest positive, non-zero absolute value representable in float type, including the range of denormalized numbers. Note that this is not the maximum value in the negative direction. |
>EOL | string | Standard newline code for the environment. |
LF | string | The newline code LF (0x0A), dependent on the environment. |
CR | string | The newline code LF CR (0x0D), dependent on the environment. |
I | complex | Imaginary unit for complex type. |
VCI | varcomplex | Imaginary unit for varcomplex type. |
NULL | “Á•Ê‚ÈŒ^ | Represents an invalid or non-existent value. Strings, structures, etc., may hold invalid values, and comparing them with NULL yields true. It is also possible to assign NULL. However, in comparison and assignment with int type, it behaves exceptionally and is equivalent to -1. Note that it is not equivalent to 0. |
Various Other Functions/Constants Available
The system functions/constants introduced here are just a subset. Beyond the system functions/constants, the entire standard library offers access to over a thousand diverse functions/constants by default. For more details, please refer to the following standard library specification:
- What is VCSSL? - Features of VCSSL
- Let's Get Started with VCSSL! - Setting Up the Environment
- Variables
- Data Types
- Arithmetic Operations
- Comparison Operations
- Logical Operations
- Scope
- Control Structures
- Arrays
- Vector Operations
- Functions
- "main" Function
- System Functions and Constants
- Standard File I/O