vipsi - sample script
Author: kio@little-bat.de
Keywords: vipsi shell script interpreter programming

# vipsi - shell and script language

## example scripts

### show_command_line_arguments.vs

this example shows how to access command line arguments which were passed to a script.

all command line arguments are simply stored as unnamed global variables. the variable globals is a list variable which contains all variables for your script. because it's a list variable you can access all items with plain vanilla list syntax; e.g. the first global variable can be displayed using `log globals[1]`.

    #!/usr/bin/vipsi

    // get number of command line arguments which are passed in the list variable globals
    // which stores all global variables. because the definition of variable argc is made before
    // count is evaluated, argc is included in the count and we must subtract it:
    //
    var argc = count globals -1;

    if argc==0
    	log "you didn't pass me any arguments!\n"
    	end
    then

    log "you told me the following words:\n"
    log "------------------------------"

    // simply convert _all_ variables to quoted:
    // that is: escape control sequences and put them in "…" quotes.
    // non-text variables (as argc) are automatically ignored.
    //
    convert globals to quoted

    // now print them in a loop:
    //
    var i = 0
    do
    	while ++i <= argc
    	log "argv[", i ,"] = ", globals[i], nl
    loop

    log "------------------------------"
    end