Menu

Hybrid Scripting Guide Line

Hybrid scripting feature in shoal script is the most amazing feature, this feature can tremendous extend the function of the shoal shell. so that the shoal shell can easily combine with other popular script language like R/Perl/JavaScript/VBScript/Python/Lua... With the combination hybrid scripting with various script language, you can using shoal shell build a powerful tool that other people can never does!

Syntax for hybrid scripting

  1. Attaching the hybrids scripting environment
    Usage: !<EntryName>

  2. Evaluate Script Expression
    Usage: var << <Expression>

  3. Set variable
    Usage: $var >> <variableName>

Example of shoal hybrid scripting with R

!r.net
csv << read.csv("test.csv")
$csv >> data
result << write.csv(data, "test_success.csv")

Here is a simple example showing how to hybrid scripting using shoal with R language, if the test is success then a new csv document named test_success.csv will be saved at the same directory with the first original test csv file.

Statement Description
!r.net Attaching the R scripting environment from the registry using its entry name r.net
csv << read.csv("test.csv") Hybrid scripting with R function read.csv and assign the R function return value to the Shoal Shell variable csv
$csv >> data Passing through the Shoal runtime and R environment runtime and assign the value of Shoal variable csv to the R variable data
result << write.csv(data, "test_success.csv") Hybrid scripting with R call the write.csv function and save the data variable which was initialized from the previous statement to the target testing file.

Another example of Shoal hybrid scripting with VBMath

Here is the example hybrid scripting interaction console output using shoal with VBMath library, and this example demonstrate the shoal work fine in the hybrid mode and the hybrid can easily extend the function of shoal: the shoal script are not about to do the mathematic evaluation but with the advantage of hybrid then the shoal script a able to proceeding the complex mathmatics expression evaluation!

$ !vbmath
Dynamic load the external "VBMath" runtime enviroment entry point, this may taks a while...
Load entry point and connect to the "VBMath" runtime enviroment successfully!
$ r << e
$ $r
= [0] 2.71828182845905

$ r << pi
$ $r
= [0] 3.14159265358979

$ r << e*pi
$ $r
= [0] 8.53973422267357

$ $r >> a
$ rr << a!
$ $rr
= [0] 362880

$ $r
= [0] 8.53973422267357

$ r << 8.53973422267357!
$ $r
= [0] 362880


Related

Wiki: Introduction

MongoDB Logo MongoDB