Step 4 - How to Add Functions/Variables by Scripts
(Library Scripts)
In this page, as an advanced step of script execution, Let's define variables/functions and use them in calculations.
You can define variables and functions in script files in "lib" folder, and use them in expressions of the Step-1 and Step-2, and in scripts of the Step-3. Scripts for providing functions/variables is referred as "library scripts" on the RINPn and the Vnano.
How to Use Library Scripts
There is an example library script "ExampleLibrary.vnano" in "lib" folder, and it is set to be loaded by default.
An example library script "ExampleLibrary.vnano" is in "lib" folder, and it is set to be loaded by default. The content of this example script is as follows:
float libvar = 2.0;
float libfun(float x) {
float result = libvar * x + 1;
return result;
}
In the expression/script inputted to the RINPn (see Step-1, Step-2, and Step-3), you can use variables and functions defined in the above "ExampleLibrary.vnano", as the following example:
1 + libvar
OUTPUT:
3
INPUT:
libfun(1.23)
OUTPUT:
3.46
How to Add New Library Scripts
If you want, you can create other (new) library script files, and define functions/variables in it.
When you have created/appended new library script files, describe its file path in the content of the text file "VnanoLibraryList.txt" in "lib" folder, for loading it.
- Introduction - Overview of the RINPn and Preparation to Use
- Step 1 - How to Use in GUI Mode (on the Calculator Window)
- Step 2 - How to Use in CUI Mode (on the Command-Line Terminal)
- Step 3 - How to Execute Scripts
- Step 4 - How to Add Functions/Variables by Scripts (Library Scripts)
- Step 5 - Implement Functions/Variables in Java® (Plug-in Development)
- Step 6 - How to Embed into Other Software
- Appendix - List of Built-in Functions/Variables