vipsi - the friendly one
Author: kio@little-bat.de
Keywords: vipsi shell script interpreter programming

# vipsi - shell and script language

## Example scripts

you may write whole programs for vipsi and save those files, formally called a script. suggested file name extension is ".vs". those scripts may be executed in a number of ways:

1. vipsi> include "myscript.vs" // include it from the vipsi shell
2. [localhost:~] kio% vipsi myscript.vs // start it from the csh shell
3. [localhost:~] kio% myscript.vs // start it from the csh shell
4. [localhost:~] kio% myscript.vs argx // start it from the csh shell and pass it some arguments

version 1 includes a program file from the vipsi shell or from a running vipsi program. all variables and procedures defined so far are preserved and may be used by the script included in the script file. all variables and procedures defined in the included script file persist after it finishs, except if they have been created in a local context; that is: between { and }.

version 2 just runs one script and exits.

version 3 requires some things to be properly setup:

- vipsi must be installed at the proper location, that is probably in: /usr/bin.
- the script must start accordingly with the line: #!/usr/bin/vipsi
- the script must be executable. in csh use chmod u+x myscript.vs for that.
- the script must be in the search path of the csh shell or you must type it's (partial) path.

version 4 requires to know how to access the arguments from within the script:

- all variables defined within a script are stored in a global list named globals.
- normally when you start vipsi this list is empty.
- if you passed arguments to a script, these arguments are stored in unnamed variables.
- you can count them with count globals and access them with globals[1] etc.

### sample script

    #!/usr/bin/vipsi

        if count globals > 0
            var i=0       // note: as a side effect, var i increases count globals by 1!
            do
                while ++i < count globals
                log "argument ",i," = ", globals[i], nl
            loop
        then
        end