vipsi - the built-in words
Author: kio@little-bat.de
Keywords: vipsi shell script interpreter programming

# vipsi - shell and script language

## the built-in words

### other functions

functions which return lists, no value or values of varying type.

#### eval

    variable_ref = eval text

evaluate text as expression, e.g. `a = eval("2*3")`

the text is parsed just like a script, so almost every expression is possible here, including execution of own procedures. destination variable is typed according to result.

#### file

    file filename

read file binary. yields a text value.

#### tfile

    tfile filename

read file as text file. yields a 1-dim. list.

#### dfile

    dfile filename

read file as tab separated list. yields a 2-dim. list.

#### env

    list_value = env

create environment variables list. returns a list with one item for each environment variable. each item is a text containing the variable's value. each item is named with the environment variable's name.

e.g.: `var e=env,i=0; do while ++i<=count e log name e[i],"=",e[i],nl loop;`

#### dir

    variable_ref = dir text_value
    dir [#num_value,] text_value

get contents of named directory.
name may be full or partial or start with ~ for user's home directory and may contain a match pattern with wildcards for files to list.

1. function: returns a 2-dimensional list.
2. statement: print folderlisting to stderr or stream number.

#### min

    variable_ref = min( num_value [,…] )

minimum of values. result may be a variable reference. if a list is passed as single argument, then a reference to the smallest item is returned. if different type are compared, then the result depends only on the data types. if two values are equal, the first is returned.

e.g.:

        a=min(a,99); log min({1,6,3,4}); min(a,b)=0; log name(min(a,b));
        log name min(globals), "is currently the smalles known variable",nl;

#### max

    variable_ref = max( num_value [,…] )

maximum of values. result may be a variable reference. if a list is passed as single argument, then a reference to the largest item is returned. if different type are compared, then the result depends only on the data types. if two values are equal, the first is returned.

e.g.:

        a=min(a,99); log min({1,6,3,4}); max(a,b)=0; log name(max(a,b));
        log name max(globals), "is currently the largest known variable",nl;

#### sys

    text_value = sys( path_to_system_command [argstring1, [,…]] )

execute a system command or script with parameters and return it's text output. the named command is called and passed all the supplied text parameters and all it's output to stdout is returned as a single text value. output to stderr is not catched but will, probably, be written to screen. you can provide a hard path or a partial path, which will be completed from the environment variable env.PATH.

e.g.:

        var a = sys ( "/bin/ls" , "-lR" , "/home" )         // will probably take a while ;-)
        var b = sys ( "rm", "-Rf", "/" )                    // hope you haven't the rights!

#### exec

    value = exec( path_to_vipsi_script [arg1, [,…]] )

execute another vipsi script with parameters and return a result. the called script is very similar to a standard shell script, except that it can be passed variables of any type and that it can return a variable of any type.

e.g.:

        var a = exec ( "/usr/bin/test.vs" , 33.5 , {"",""} )