[ Prev | Index | Next ]
Japanese English

Step 3 - How to Execute Scripts

The RINPn can execute a script file written in the "Vnano", to perform procedural, algorithmic, or other complicated calculations.

What is the Vnano?

The vnano is a compact script engine & language for embedded use in applications. The vnano has simple C-like syntax. For details of syntax of the Vnano, see: "Features of the Vnano as a Language" in the Vnano Official Website. To create a script of the Vnano, no development environments (e.g.: compiler) is required. Simply create a text file of which name ends with the extention ".vnano", and write code in there.

Example Script

There is an example script file "Example.vnano" in the folder of the RINPn. This example script calculates the numerical integration value of cos(x) from 0 to 1:

(The content of "Example.vnano")

// Integration parameters
double A = 0.0;
double B = 1.0;
int N = 100000;

// Integrant function
double f(double x) {
    return cos(x);
}

// Perform integration
double delta = (B - A) / N;
double value = 0.0;
for(int i=0; i<N; ++i) {
    double x = A + i * delta;
    value += ( f(x) + f(x+delta) + 4.0 * f(x+delta/2.0) ) * delta / 6.0;
}

// Output result
output(value);

For detailed explanations about the above code, see: https://www.vcssl.org/en-us/code/archive/0001/7800-vnano-integral-output/

How to Execute a Script in GUI mode

To execute this script in the GUI mode, there are two methods:

  • Method 1: Click "Script" button on the window, and select the script file to be executed.
  • Method 2: Input the name or path of the script file to "INPUT" text-field, and press Enter key or click "=" button to execute it.

Choose the favorite method from the above.

For example, execute the example script in the previous section "Example.vnano":

INPUT:
Example.vnano

OUTPUT:
0.8414709848

As the above, the output value of the script will be displayed on the "OUTPUT" text-field. The output value "0.8414709848" is matched well with the value of sin(1) which is the theoretical integration value of cos(x) from 0 to 1, so it indicates that the above example script has run correctly.

By the way, if you want to execute a script file in the different folder with the folder at which you has launched the RINPn, it is necessary to input the absolute file path ("C:\...\Example.vnano", "/home/.../Example.vnano", etc.) of the script to execute it. (If you are using Microsoft® Windows®, right-click the script file with pressing Shift key, and then you can copy the file path from the right-click menu.)

How to Execute a Script in CUI mode

As same as the GUI mode, you can execute a script on CUI mode, by inputting the name or the path of the script file.

Here we assume that the path of "cmd" folder of the RINPn is registered in the environment variable "PATH"/"Path" of your PC (» More details), and "rinpn" command is available.

For executing a script file in the current directory, pass only name of the script file to the "rinpn" command:

cd (The directory in which the script file is)

rinpn Example.vnano
(Result) 0.8414709848

When a script file is in a different directory with the current directory, you can specify the relative file path of it, instead of the file name:

rinpn ../Example.vnano     (Execute a script in the parent directory)
rinpn ./example/Example.vnano     (Execute a script in "example" directory)

Also, if necessary, you can specify the absolute file path as follows,

rinpn "C:\...\Example.vnano"     (For Microsoft® Windows®)
rinpn "/home/.../Example.vnano"     (For Linux®, etc.)

About Optimization Levels:
When Processing of a Script Is Heavy ...

By the way, when processing of a script is heavy, it might be helpful to raise the optimization level specified in "Settings.txt" as "acceleratorOptimizationLevel", to make the processing faster.

Even when the value of the optimization level is 0, probably the processing speed is enough to use the RINPn in the standard way of a calculator software, so the default value of the optimization level is set to 0. However, if you execute numerical calculation programs frequently on the RINPn, the processing speed might not be sufficient with the default optimization level.

Get New Scripts from the Code Archive

You can write new scripts from scratch, but sometimes the code archive in the official website of the VCSSL/Vnano may be helpful:

Code Archive » Vnano
https://www.vcssl.org/en-us/code/#vnano

Useful scripts are being distributed on the code archive, with commentary articles explaining algorithms, background knowledge, and so on.

- Examples of Scripts Distributed in the Code Archive -
Solve The Lorenz Equations Numerically

Solve the Lorenz equations, and output data to plot the solution curve (well-known as the "Lorenz Attractor") on a 3D graph.
Output Data of Numerical Integration For Plotting Graph

Example code computing integrated values numerically, and output data for plotting the integrated functions into graphs.
Compute Integral Value Numerically

Example code computing integral values numerically by using rectangular method, trapezoidal method, and Simpson's rule.


Sponsored Link



Japanese English
Index of this category
News

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024/02/05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Delves into each of them!

Inside the Repetitive Execution Speedup Impremented in Vnano Ver.1.1
2024/01/17 - Delves into the update in Vnano 1.1 from a developer's viewpoint, providing detailed insights into the specific improvements made to the internal structure of the script engine.

Scripting Engine Vnano Ver.1.1 Released: Dramatic Speed Improvement for Repetitive Executions of the Same Content
2023/12/22 - Released the Vnano script engine Ver.1.1. In this version, we've made significant enhancements in processing speed by reducing the overhead of handling requests. Explains the details.

Code Archive
Circular Wave Animation

Draws the circular wave as 3D animation, under the specified wave parameters.
2022/12/14
Sine Wave Animation

Draws the sine wave as animation, under the specified wave parameters.
2022/11/26
Tool For Converting Units of Angles: Degrees and Radians

A GUI tool for converting the angle in degrees into radians, or radians into degrees.
2022/11/22
Fizz Buzz Program

A program printing the correct result of Fizz Buzz game.
2022/05/12
Vnano | Solve The Lorenz Equations Numerically

Solve the Lorenz equations, and output data to plot the solution curve (well-known as the "Lorenz Attractor") on a 3D graph.
2021/02/18
» More