vipsi - the friendly vip script interpreter

Data Types

Flow control: if … then
Flow control: try … then
The
vip Example Scripts: CGI Scripts
Example Scripts: Scripts
script
language knows about 4 Data Types
Invariants: Data types
data types
:

  1. Data Types: NumbersNumbers
  2. Data Types: Text
    Glossary: text, text_val
    Text
  3. Data Types: Lists and arrays
    Glossary: list, list_val
    Lists
    / Data Types: Lists and arraysarrays
  4. Vipsi command syntax: Procedures
    Data Types: Procedures
    Glossary: Procedure
    Procedures

Sometimes Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
itself may be considered as a 5Flow control: if … then
Flow control: try … then
th
Data Types
Invariants: Data types
data type
.

Numbers

Data Types: NumbersNumbers are stored internally in an 8-byte IEEE Number literals: Floating pointfloating point format (except Flow control: if … thenif List functions: thisthis format is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
available) which allows for a precision of up to 53 bits including Numeric functions: signsign bit (approx. ±16 Number literals: Decimal
Integer numbers: Decimal
Floating point: Decimal
decimal
digits) Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
an exponent of 11 bits (approx. ±308 Number literals: Decimal
Integer numbers: Decimal
Floating point: Decimal
decimal
digits).

Support for 10-byte IEEE Data Types: Numbersnumbers as a compile-time option is planned (as of version 0.8.7), which will give you 64 bit accuracy.

Maximum values are:
Numeric functions: minmin./Numeric functions: maxmax. integer:        ±((1<<53)-1)
                        = ±9.007199254741e+15

Numeric functions: minmin./Numeric functions: maxmax. Glossary: Valuevalues:         ±(((1<<53)-1)<<52)<<1023
                        = ±1.7976931348623e+308

nearest Glossary: Valuevalues to null:   ±1>>1022
(full precision)        = ±2.2250738585072e-308

nearest Glossary: Valuevalues to null:   ±(1>>52)>>1022
(denormalized)          = ±4.9406564584125e-324

Besides that are some abnormal monstrosities like NaNs Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
signed zeros. I hope for your sake that you never need it. B-)

Number literals

Literals: Number literals
Numbers: Number literals
Number literals
can be written in multiple styles. All Literals: Number literals
Numbers: Number literals
number literals
can be preceded by a Glossary: number, num_valnumber Numeric functions: signsign '+' Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
'-'.

Integer numbers

Decimal

Literals: Number literals
Numbers: Number literals
Number literals
with Integer numbers: Base 256base 10:

1234
-1234
+234567
Hexadecimal

Literals: Number literals
Numbers: Number literals
Number literals
with Integer numbers: Base 256base 16 are introduced with a dollar Numeric functions: signsign '$':

$123affe
-$adf
+$adfeee
Binary

Literals: Number literals
Numbers: Number literals
Number literals
with Integer numbers: Base 256base 2 are introduced with a percent Numeric functions: signsign '%':

%10100101
%1011010010101010101010101010100101
+%10100101
-%010111
Base 256

Literals: Number literals
Numbers: Number literals
Number literal
with 'character digits'. Each character represents a digit in range [0 .. 255]. Flow control: if … thenIf you Functions with varying return types: include
Instructions: include
include
characters with a character code greater than 255 Flow control: if … then
Flow control: try … then
then
the character code is silently chopped.

'a'
'bee'
+'mixa'
-'AFFE'
'2A\'s'             escaping a "'"
'\n'                other escape codes are allowed too
'\x1e'              see --> Escape characters

Floating point

Number literals: Floating pointFloating point Glossary: number, num_valnumber can be written with a Number literals: Decimal
Integer numbers: Decimal
Floating point: Decimal
decimal
, Integer numbers: Hexadecimal
Floating point: Hexadecimal
Text functions: hexstr
hexadecimal
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Integer numbers: Binary
Floating point: Binary
Text functions: binstr
binary
Glossary: number, num_valnumber Integer numbers: Base 256base. Scientific notation (with exponent) is only supported for Number literals: Decimal
Integer numbers: Decimal
Floating point: Decimal
decimal
Data Types: Numbersnumbers.

Decimal
-123.456
0.456
123.456e78          scientific notation
+123.456e-78
.123                List functions: thisthis is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
a Glossary: number, num_valnumber!
Hexadecimal
$0.FFFFFFFF
-$b00.b00f
+$afddb00.00d
Binary
%101000.00101
+%1010.0101
-%1010.010100

Text

Data Types: Text
Glossary: text, text_val
Text
is stored internally in a format that allows for virtually any Data Types: Text
Glossary: text, text_val
text
dir: lengthlength Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
can store any unicode character (Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
beyond) including character code 0. There is no problem storing Integer numbers: Binary
Floating point: Binary
Text functions: binstr
binary
daty in Data Types: Text
Text functions: string
strings
. In fact, it is common practice to Instructions: readread whole Text functions: file
Instructions: file
files
into a Data Types: Text
Text functions: string
string
before starting work on Flow control: if … then
Flow control: try … then
them
. ;-)

When reading Data Types: Text
Glossary: text, text_val
text
from a Text functions: file
Instructions: file
file
in Integer numbers: Binary
Floating point: Binary
Text functions: binstr
binary
mode Flow control: if … then
Flow control: try … then
the
resulting Data Types: Text
Glossary: text, text_val
text
consists only of characters with codes in range [0 .. 255]. You can Flow control: do … loopdo manual conversion with Text functions: convert
Instructions: convert
convert
Flow control: if … thenif required, mocrifying your Integer numbers: Binary
Floating point: Binary
Text functions: binstr
binary
data into a real Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
unicode compliant Data Types: Text
Glossary: text, text_val
text
. When reading a Data Types: Text
Glossary: text, text_val
text
in Flow control: if … then
Flow control: try … then
the
preferred way with Instructions: getget from an opened stream Flow control: if … then
Flow control: try … then
then
you Instructions: getget Data Types: Text
Glossary: text, text_val
text
, Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
Integer numbers: Binary
Floating point: Binary
Text functions: binstr
binary
data, Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
conversion is already done for you. Flow control: if … then
Flow control: try … then
The
default encoding is UTF-8. Writing to Text functions: file
Instructions: file
files
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
streams works similar - just reverse.

Text literals

Literals: Text literals
Text: Text literals
Text literals
are written 'as is' Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
enclosed in either of two types of Separatorsseparators:

"hello"             a simple Data Types: Text
Glossary: text, text_val
text
«say "hello"» a simple Data Types: Text
Glossary: text, text_val
text
which contains quotes "List functions: thisthis is a longish Literals: Text literals
Text: Text literals
text literal
which Functions with varying return types: include
Instructions: include
includes
two line breaks.\n" Instructions: var
How does VScript::Value() work?: Var*&
var
myText = "List functions: thisthis is a long Literals: Text literals
Text: Text literals
text literal
\ which spans multiple lines \ but which Flow control: do … loopdoes Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
Functions with varying return types: include
Instructions: include
include
Flow control: if … then
Flow control: try … then
the
line breaks \ Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
indentation characters."

Literals: Text literals
Text: Text literals
Text literals
can enclose any character, including line breaks, but except Flow control: if … then
Flow control: try … then
the
closing Separatorsseparator. Some control codes may be hard too. B-)

Escape character

Control codes Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
characters with special meaning, that is, Flow control: if … then
Flow control: try … then
the
Text literals: Escape characterescape character Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
closing Separatorsseparator, Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
most other characters too can be escaped using c- Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
bash-style character escaping Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
encoding introduced with Flow control: if … then
Flow control: try … then
the
backslash '\' character:

\\      escapes Flow control: if … then
Flow control: try … then
the
Text literals: Escape characterescape character \" escapes Flow control: if … then
Flow control: try … then
the
closing Separatorsseparator in ".." Data Types: Text
Text functions: string
strings
\» escapes Flow control: if … then
Flow control: try … then
the
closing Separatorsseparator in «..» Data Types: Text
Text functions: string
strings
\123 circumscribes a character with octal notation character code range: [0 .. 255] \x1a circumscribes a character with Integer numbers: Hexadecimal
Floating point: Hexadecimal
Text functions: hexstr
hexadecimal
notation character code range: [0 .. 255] \cX circumscribes a control character by applying a bit mask character code range: [0 .. 31] \n circumscribes a character with it's 'well known Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
' List functions: thisthis is Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
: \e \a \b \f \n \r \t \v $1B $07 $08 $0C $0A $0D $09 $0B \ Operators: Make Identifier "@"at Flow control: end
Shell Immediate Commands: exit, quit, end
end
of line: discards Flow control: if … then
Flow control: try … then
the
line break Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
all white space up to Flow control: if … then
Flow control: try … then
the
first printable character. Used to break up Data Types: Text
Glossary: text, text_val
text
in Literals: Text literals
Text: Text literals
text literals
for readability.

A "\" backslash before any other character without special meaning is simply discarded.

Short survey on substrings

Individual characters Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
substrings are accessed with either Text functions: leftstrleftstr() Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
like Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
an array-like notation:

Instructions: putput "Anton"[3]                 // prints: t
Instructions: putput "Anton Bruckner"[3 to 5]   // prints: ton
Instructions: putput "Caesar Cicero"[to 5]      // prints: Caesar
Instructions: putput "Caesar Cicero"[8 to]      // prints: Cicero
Instructions: putput "Casiopeia"[ to ]          // prints: Casiopeia

Numeric functions: indexIndexes start Operators: Make Identifier "@"at 1, ranges are declared with Flow control: if … then
Flow control: try … then
the
first Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
last Numeric functions: indexindex inclusive.

Lists and arrays

Data Types: Lists and arrays
Glossary: list, list_val
Lists
may be of any size Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
nested to any level Flow control: untiluntil you run out of RAM.

List literals

Data Types: Lists and arrays
Glossary: list, list_val
Lists
can be initialized with { ... } in one go, including nested sub-lists Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
naming of Data Types: Lists and arrays
Glossary: list, list_val
list
items.

Instructions: putput { }                   an empty Data Types: Lists and arrays
Glossary: list, list_val
list
Instructions: putput { 1, 2, 3 } a Data Types: Lists and arrays
Glossary: list, list_val
list
with three items Instructions: putput { "a", "b", 44 } again three items Instructions: putput { 1, {"a","b"} } two items. Flow control: if … then
Flow control: try … then
the
second item itself is a Data Types: Lists and arrays
Glossary: list, list_val
list
Instructions: putput { x=22, y=1.5, z=0 } items may by named
Printing list literals in the vipsi shell

Separators: Curly brackets "{ … }"Braces { ... } are also used to enclose ranges of program code with a private Glossary: Variable, var_refvariable scope. Therefore Flow control: if … then
Flow control: if … then
if the
interpreter encounters { where it expects an Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
it starts a private Glossary: Variable, var_refvariable scope Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
a Data Types: Lists and arrays
Glossary: list, list_val
list
definition. Flow control: if … then
Flow control: try … then
The
only place where List functions: thisthis may lead to confusion is in Flow control: if … then
Flow control: try … then
the
vipsi shell: Operators: Make Identifier "@"At Flow control: if … then
Flow control: try … then
the
start of Flow control: if … then
Flow control: try … then
the
command line Flow control: if … then
Flow control: try … then
the
interpreter expects an Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
. Flow control: if … thenIf you just type in

{ x=22, y=1.5, z=0 }

to see whether it evaluates your Literals: List literals
Lists and arrays: List literals
list literal
as expected, assuming that you always can type in any Vipsi command syntax: Expressions
Glossary: Expression
expression
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
shell will print your result, you'll Numeric functions: findfind that List functions: thisthis won't work here. That's why i have always written Instructions: putput in front of Flow control: if … then
Flow control: try … then
the
examples above.

Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
note
: maybe i'll Operators: Add to Variable "+="
Operators: Add "+"
add
a glue to Flow control: if … then
Flow control: try … then
the
shell to detect an opening Separators: Curly brackets "{ … }"brace Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
start a Literals: List literals
Lists and arrays: List literals
list literal
instead a private Glossary: Variable, var_refvariable scope. After all, starting a private Glossary: Variable, var_refvariable scope on Flow control: if … then
Flow control: try … then
the
command line is even more unlikely. B-)

Short survey on sublists and access to single items

Individual items Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
substrings are accessed either by Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
with an array-like notation:

Numeric functions: indexIndexes start Operators: Make Identifier "@"at 1, ranges are declared with Flow control: if … then
Flow control: try … then
the
first Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
last Numeric functions: indexindex inclusive.

Accessing an item beyond Flow control: if … then
Flow control: try … then
the
Flow control: end
Shell Immediate Commands: exit, quit, end
end
of a Data Types: Lists and arrays
Glossary: list, list_val
list
automatically creates all intermediate items, which are unnamed Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
set to Glossary: number, num_valnumber Glossary: Valuevalue 0.0.

Instructions: var
How does VScript::Value() work?: Var*&
var
my_list = { 1, 2, 3, a=4, b=5, c=6 } Instructions: putput my_list.a // prints: 4 Instructions: putput my_list[3] // prints: 3 Instructions: putput my_list[3 to 5] // prints: { 3, a=4, b=5 } Instructions: putput my_list[to 4] // prints: { 1, 2, 3, a=4 } Instructions: putput my_list[5 to] // prints: { b=5, c=6 } Instructions: putput my_list[ to ] // prints: { 1, 2, 3, a=4, b=5, c=6 }
Instructions: var
How does VScript::Value() work?: Var*&
var
list2 = { 1, z={ 2, z="Anton", 3}, 4 } Instructions: putput list2.z // prints: { 2, z="Anton", 3 } Instructions: putput list2.z.z // prints: Anton Instructions: putput list2[2,2,to 3] // prints: Ant Instructions: putput list2.z[2,to 3] // prints: Ant
Instructions: var
How does VScript::Value() work?: Var*&
var
list3={} // create empty Data Types: Lists and arrays
Glossary: list, list_val
list
list3[100] // resize Data Types: Lists and arrays
Glossary: list, list_val
list
to 100 elements
Instructions: var
How does VScript::Value() work?: Var*&
var
i = Numeric functions: intint(Numeric functions: randomrandom(2)) +1 Instructions: putput { "foo", "bär" }[i]

Procedures

Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedures
are a Data Types
Invariants: Data types
data type
. Once defined, they can be executed, disassembled, passed to other Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedures
as Vipsi command syntax: Arguments
Glossary: Arguments
argument
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Instructions: putput into a Data Types: Lists and arrays
Glossary: list, list_val
list
.

Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedures
can be called recursively.

Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedures
in a Data Types: Lists and arrays
Glossary: list, list_val
list
can access 'neighbour' data elements by Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
, thus supplying a light-weight approach for object oriented programming.

Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedures
can either take a fixed Glossary: number, num_valnumber of Vipsi command syntax: Arguments
Glossary: Arguments
arguments
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
a Glossary: Variable, var_refvariable amount, indicated with an asterics *.

They can Flow control: returnreturn a result of any Data Types
Invariants: Data types
data type
(Glossary: number, num_valnumber, Data Types: Text
Glossary: text, text_val
text
, Data Types: Lists and arrays
Glossary: list, list_val
list
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
) Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
no result. Flow control: if … then
Flow control: try … then
The
result they Flow control: returnreturn may vary depending on Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Arguments
Glossary: Arguments
argument
data Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
other criteria.

Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedures
may be defined locally inside other Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedures
. Because they can access 'neighbour' data items, they can access Flow control: if … then
Flow control: try … then
the
List functions: localslocal data of Flow control: if … then
Flow control: try … then
the
enclosing Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
.

Procedure literals

Literals: Procedure literals
Procedures: Procedure literals
Procedure literals
start with Flow control: if … then
Flow control: try … then
the
keyword Instructions: procproc, followed by Separators: Round brackets "( … )"parenthesis surrounding Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Arguments
Glossary: Arguments
arguments
Data Types: Lists and arrays
Glossary: list, list_val
list
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Separators: Curly brackets "{ … }"braces surrounding Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Statements
Glossary: Statement
statements
to execute.

<procedure> = Instructions: procproc ( <arguments> ) { <statements> }

Flow control: if … then
Flow control: try … then
The
more common way to define a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
is with Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
Instructions: procproc.

Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
Instruction
Instructions: procproc creates a Glossary: Variable, var_refvariable Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
stores Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
in one go. Flow control: if … then
Flow control: try … then
The
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
itself is written in a form very similar to that of a Literals: Procedure literals
Procedures: Procedure literals
procedure literal
. Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
Instruction
Instructions: procproc is a short form for creating a Glossary: Variable, var_refvariable as with Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
Instructions: var
How does VScript::Value() work?: Var*&
var
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
assigning it a Literals: Procedure literals
Procedures: Procedure literals
procedure literal
as initial Glossary: Valuevalue. Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
Note
Flow control: if … then
Flow control: try … then
the
difference:

Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
Instruction
Instructions: procproc:

Instructions: procproc <name> ( <arguments> ) { <statements> }

Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
Instruction
Instructions: var
How does VScript::Value() work?: Var*&
var
with Literals: Procedure literals
Procedures: Procedure literals
procedure literal
as initial Glossary: Valuevalue:

Instructions: var
How does VScript::Value() work?: Var*&
var
<name> = Instructions: procproc ( <arguments> ) { <statements> }

Using a real Literals: Procedure literals
Procedures: Procedure literals
procedure literal
is sometimes convenient Flow control: if … thenif you want to Instructions: putput it in a Data Types: Lists and arrays
Glossary: list, list_val
list
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
Flow control: if … thenif you want to pass it to another Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
as an Vipsi command syntax: Arguments
Glossary: Arguments
argument
.

When you Text functions: convert
Instructions: convert
convert
a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
a Data Types: Lists and arrays
Glossary: list, list_val
list
containing a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
to a Data Types: Text
Text functions: string
string
, which is implicitely done when you print it using Instructions: putput, it is reverted to it's Vipsi command syntax: Literals
Glossary: Literal
literal
appearance.

Store Literals: Procedure literals
Procedures: Procedure literals
procedure literal
in a Glossary: Variable, var_refvariable:

Instructions: var
How does VScript::Value() work?: Var*&
var
foo = Instructions: procproc(bär) { Flow control: returnreturn bär } Instructions: var
How does VScript::Value() work?: Var*&
var
z = Instructions: procproc() { Instructions: putput "hi" }

Store Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
somewhere into a Data Types: Lists and arrays
Glossary: list, list_val
list
:

Instructions: var
How does VScript::Value() work?: Var*&
var
mylist = {} mylist[100] = Instructions: procproc() { Instructions: putput "foobär" } Instructions: putput mylist[100] // print item 100. prints disassembly mylist[100]() // execute Flow control: if … then
Flow control: try … then
the
Instructions: procproc. prints foobär

A Literals: Procedure literals
Procedures: Procedure literals
procedure literal
as part of a Literals: List literals
Lists and arrays: List literals
list literal
:

Instructions: var
How does VScript::Value() work?: Var*&
var
mylist = { 22, 33, z=Instructions: procproc(){Flow control: returnreturn List functions: thisthis[1]+List functions: thisthis[2]} } Instructions: putput mylist.z // prints Flow control: if … then
Flow control: try … then
the
Instructions: procproc: disassembly Instructions: putput mylist.z() // prints Shell Scripts: Return values
Appendix: Return values
return value
of Instructions: procproc: 55

A Literals: Procedure literals
Procedures: Procedure literals
procedure literal
as Vipsi command syntax: Arguments
Glossary: Arguments
argument
to another Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
:

SetMyFooIterator ( Instructions: procproc(i){Flow control: returnreturn i+1} );

But in most cases you would first define a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
then
pass List functions: thisthis Glossary: Variable, var_refvariable as an Vipsi command syntax: Arguments
Glossary: Arguments
argument
, because Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedures
tend to be a little bit longish. ;-)

Identifiers, names

You need Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
for your Glossary: Variable, var_refvariables Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedures
. Also each item in a Data Types: Lists and arrays
Glossary: list, list_val
list
may be named. In fact, all Glossary: Variable, var_refvariables that you define are Instructions: putput in a Data Types: Lists and arrays
Glossary: list, list_val
list
which is named List functions: globals
Shell Immediate Commands: globals
globals
.

There are nearly no restrictions on Glossary: Variable, var_refvariable Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
. Any sequence of data may be used as a Glossary: Variable, var_refvariable's Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
. but there are restrictions on Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
which are recognized by vipsi easily.

Flow control: if … then
Flow control: try … then
The
following rules must be obeyed for Instructions: newnew Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
:

Examples of legal names:
 anton, cäsar, µ, ΩOperators: Subtract "-"sub, sin21, _, _liste_, Café, Smørebrød, Жизмн.
Examples of illegal names:
catch 23      contains space
Numeric functions: sinsin           pre-defined List functions: words
Shell Immediate Commands: words
word
6pack starts with a Glossary: number, num_valnumber big-letters no '-' allowed

No restrictions on names

In fact, Flow control: if … then
Flow control: try … then
the
above restrictions are only imposed on Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
parser. Glossary: Variable, var_refVariable Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
may be really any Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
.
e.g. frequently you have Glossary: Variable, var_refvariables with an empty Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
, e.g. command line Vipsi command syntax: Arguments
Glossary: Arguments
arguments
which are stored as unnamed Glossary: Variable, var_refvariables in Flow control: if … then
Flow control: try … then
the
List functions: globals
Shell Immediate Commands: globals
globals
Data Types: Lists and arrays
Glossary: list, list_val
list
Glossary: Variable, var_refvariable Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
most commonly unnamed items in Data Types: Lists and arrays
Glossary: list, list_val
lists
. You can create Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
access Flow control: if … then
Flow control: try … then
them
with Flow control: if … then
Flow control: try … then
the
help of Flow control: if … then
Flow control: try … then
the
@ prefix Vipsi command syntax: Operators
Operators
Glossary: Operator
operator
:

// define Glossary: Variable, var_refvariable with Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
"55": Instructions: var
How does VScript::Value() work?: Var*&
var
@"55" = 66; Instructions: putput @"55" // fetch Glossary: Variable, var_refvariable by a computed Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
: Instructions: var
How does VScript::Value() work?: Var*&
var
vname=""; Instructions: putput Constants: nlnl,"which Instructions: var
How does VScript::Value() work?: Var*&
var
? "; Instructions: getget vname; Flow control: if … thenif(Numeric functions: existsexists @vname) Instructions: putput " = ",@vname,Constants: nlnl Flow control: if … then
Flow control: try … then
else
Instructions: putput "Flow control: do … loopdoes Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
Numeric functions: existsexist",Constants: nlnl Flow control: if … then
Flow control: try … then
then
// Instructions: renamerename Glossary: Variable, var_refvariables to computed Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
: Instructions: var
How does VScript::Value() work?: Var*&
var
Data Types: Text
Glossary: text, text_val
text
= Text functions: file
Instructions: file
file
("test Text functions: file
Instructions: file
file
.txt") List functions: split
Instructions: split
split
Data Types: Text
Glossary: text, text_val
text
// List functions: split
Instructions: split
split
Data Types: Text
Glossary: text, text_val
text
Operators: Make Identifier "@"at line breaks --> Data Types: Lists and arrays
Glossary: list, list_val
list
of Glossary: text_ref, text_vartexts var i=0 Flow control: do … loopdo Flow control: whilewhile ++i <= Numeric functions: countcount Data Types: Text
Glossary: text, text_val
text
Instructions: renamerename Data Types: Text
Glossary: text, text_val
text
[i] = Data Types: Text
Glossary: text, text_val
text
[i] Flow control: do … looploop

In About this Guide: General
Built-in operators: General
general
you won't need it Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
it is a feature sys: For experts:for experts Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
beginners. See Flow control: if … then
Flow control: try … then
the
Example Scriptsexample script "count_words.vs" for an application of List functions: thisthis feature.

Scope of names

You can Operators: Select "? :"select a named item in any Data Types: Lists and arrays
Glossary: list, list_val
list
with Flow control: if … then
Flow control: try … then
the
"." Vipsi command syntax: Operators
Operators
Glossary: Operator
operator
. Whenever a Data Types: Lists and arrays
Glossary: list, list_val
list
is searched for a given Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
, Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
search starts Operators: Make Identifier "@"at Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
Flow control: end
Shell Immediate Commands: exit, quit, end
end
. Flow control: if … then
Flow control: if … then
If the
Data Types: Lists and arrays
Glossary: list, list_val
list
contains more than one item with Flow control: if … then
Flow control: try … then
the
same Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
, Flow control: if … then
Flow control: try … then
then
searching for that Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
Flow control: returnreturns Flow control: if … then
Flow control: try … then
the
last item.

Operators: Make Identifier "@"At 'ground level', that is outside any Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
, all Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
are searched in Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
of List functions: globals
Shell Immediate Commands: globals
global
Glossary: Variable, var_refvariables.

You can create nested ranges of Vipsi command syntax: Statements
Glossary: Statement
statements
with private Glossary: Variable, var_refvariable scope using Separators: Curly brackets "{ … }"braces: { ... }. Flow control: if … then
Flow control: try … then
Then
Flow control: if … then
Flow control: try … then
the
search starts in Flow control: if … then
Flow control: try … then
the
innermost privates scope, extending to Flow control: if … then
Flow control: try … then
the
outer private scopes up to Flow control: if … then
Flow control: try … then
the
List functions: globals
Shell Immediate Commands: globals
global
scope, Flow control: untiluntil an item of Flow control: if … then
Flow control: try … then
the
requested Vipsi command syntax: Identifiers (names)
Data Types: Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
ist found.

Inside a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Flow control: if … then
Flow control: try … then
the
search Functions with varying return types: include
Instructions: include
includes
Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
of List functions: localslocal Glossary: Variable, var_refvariables Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
which contains Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
itself. Flow control: if … then
Flow control: try … then
The
exact sequence is like List functions: thisthis:

  1. innermost { .. } private scope ...
    ... List functions: localslocals of Flow control: if … then
    Flow control: try … then
    the
    Vipsi command syntax: Procedures
    Data Types: Procedures
    Glossary: Procedure
    procedure
  2. Data Types: Lists and arrays
    Glossary: list, list_val
    List
    which contains Flow control: if … then
    Flow control: try … then
    the
    Vipsi command syntax: Procedures
    Data Types: Procedures
    Glossary: Procedure
    procedure
  3. innermost { .. } private scope ...
    ... List functions: globals
    Shell Immediate Commands: globals
    globals
    of Flow control: if … then
    Flow control: try … then
    the
    program

What is 'searching Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Glossary: list, list_val
list
which contains Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
' good for?

Flow control: if … then
Flow control: try … then
The
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
might be locally defined inside another Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
. Flow control: if … then
Flow control: try … then
Then
Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
is a List functions: localslocal Glossary: Variable, var_refvariable. Using Flow control: if … then
Flow control: try … then
the
parent Data Types: Lists and arrays
Glossary: list, list_val
list
search it can easily access all List functions: localslocal Glossary: Variable, var_refvariables of Flow control: if … then
Flow control: try … then
the
enclosing Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
too.

Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
Or
you Instructions: putput Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedures
into complicated Data Types: Lists and arrays
Glossary: list, list_val
lists
to manage some aspects, offering a light-weight approach to object oriented programming.

Valid HTML   Valid CSS