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

### numeric functions

functions which return numeric (incl. boolean) values.

#### mdate

    mdate filename

get modification date of file. yields a numeric value.

#### count

    count text|list

querry number of elements in text or list.

#### index

    index value

get position of item in list.

#### random

    random num_value

get a random number in range [0 … [n (float!)

#### abs

    abs num_value

unsigned, absolute value of numeric value.

#### sign

    sign num_value

sign of numeric value.

#### int

    int num_value

integral part of numeric value.

#### fract

    fract num_value

fractional part of numeric value.

#### round

    round num_value

round to nearest. xx.5 rounds upwards.

#### cos

    num_value = cos num_value

cosinus of angle. full circle = 2*pi.

#### sin

    num_value = sin num_value

sinus of angle. full circle = 2*pi.

#### tan

    num_value = tan num_value

tangens of angle. full circle = 2*pi.

#### acos

    num_value = acos num_value

angle from cosinus. result range: 0 … +pi.

#### asin

    num_value = asin num_value

angle from sinus. result range: -pi/2 … +pi/2.

#### atan

    num_value = atan num_value

angle from tangens. result range: -pi/2 … +pi/2.

#### cosh

    num_value = cosh num_value

cosinus hyperbolicus. example?

#### sinh

    num_value = sinh num_value

sinus hyperbolicus. example?

#### tanh

    num_value = tanh num_value

tangens hyperbolicus. example?

#### logn

    num_value = logn( num_value1, num_value2 )

logarithm of number 2 to base number 1. e.g.: `logn(16,256) = 2.`

#### log2

    num_value = log2 num_value

logarithm of number to base 2. e.g.: `log2(4) = 2.`

#### loge

    num_value = loge num_value

logarithm of number to base e. e.g.: `loge(e*e) = 2.`

#### log10

    num_value = log10 num_value

logarithm of number to base 10. e.g.: `log10(100) = 2.`

#### exp

    num_value = exp( num_value1, num_value2 )

number 1 raised to the power of number 2. e.g. `exp(16,2) = 256.`

#### exp2

    num_value = exp2 num_value

2 raised to the power of number. e.g. `exp2(3) = 8.`

#### expe

    num_value = expe num_value

e raised to the power of number. e.g.: `expe(2) = e*e.`

#### exp10

    num_value = exp10 num_value

10 raised to the power of number. e.g.: `exp10(2) = 100.`

#### square

    num_value = square num_value

number * number. e.g.: `square 5 = 25.`

#### sqrt

    num_value = sqrt num_value

square root of number. e.g.: `sqrt 25 = 5.`

#### charcode

    num_value = charcode text_value

convert first character in text to character code number. e.g.: `charcode "€" = 8364.`

#### now

    num_value=now

get system time. returns local time in seconds incl. a fractional part. time base may vary!

e.g.

        log"current date and time = ",datestr(now),nl;
        var a=0,t0=now; do while ++a<100000; loop; put "time=",now-t0;

#### dateval

    num_value = dateval text_value

convert readable date text to numeric format.

e.g.:

        dateval "2002-04-01 12:00" = 1017658800.
        dateval "2002.04"          = 1017529200.

#### find

    num_value=find(text_value1,text_value2)

find first occurance of text 2 in text 1. returns index of position found or 0.

e.g.: `find("hello world","l") = 3.`

#### rfind

    num_value = rfind(text_value1,text_value2)

find last occurance of text 2 in text 1. returns index of position found or 0.

e.g.: `rfind("hello world","l") = 10.`

#### istext

    num_value = istext value

test whether expression is a text value.

e.g.: `istext("foo") = 1; istext({}) = 0.`

#### isnumber

    num_value = isnumber value

test whether expression is a numeric value.

e.g.: `isnumber(1+2) = 1; isnumber({}) = 0.`

#### islist

    num_value = islist value

test whether expression is a list.

e.g.: `islist({1,2}) = 1; islist(12) = 0.`

#### isproc

    num_value = isproc value

test whether expression is a user-defined procedure.

e.g.: `proc foo(){}; isproc(foo) = 1; isproc("foo") = 0.`

#### isfile

    num_value = isfile text_value

test whether path refers to a file.

e.g.: `var a = isfile("~/bin/vipsi");`

#### isdir

    num_value = isdir text_value

test whether path refers to a directory.

e.g.: `isdir("/") = 1; isdir("") = 0.`

#### exists

    num_value = exists variable_ref

test whether variable exists.

e.g.: `var a={1,2,3}; exists a[3] = 1; exists a[5] = 0.`

#### match

    num_value = match( text_value1, text_value2 [,num_value] )

test whether text 1 matches pattern in text 2. returns boolean value: 0 (no) or 1 (yes).

the optional flag consists of 3 bits:

            1 = enable backslash escaping
            2 = slash must match slash (e.g. file paths)
            4 = dot must match dot (e.g. file names)