vipsi - the friendly vip script interpreter

Flow control

List functions: thisThis group of Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
modifies Flow control: if … then
Flow control: try … then
the
linear flow of program execution into Flow controlbranches Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: do … looploops. There is also Flow control: if … then
Flow control: try … then
the
error catcher with 'Flow control: try … thentry' Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
termination with 'Flow control: end
Shell Immediate Commands: exit, quit, end
end
'.

do … loop

Flow control: do … loopdo
    <statements>
Flow control: do … looploop

Flow control: do … loopdo
    Flow control: whilewhile <condition>
    Flow control: untiluntil <condition>
    Flow control: if … thenif <value> Flow control: nextnext Flow control: if … then
Flow control: try … then
then
Flow control: if … thenif <value> Flow control: exit
Shell Immediate Commands: exit, quit, end
exit
Flow control: if … then
Flow control: try … then
then
Flow control: do … looploop

Repeat Vipsi command syntax: Statements
Glossary: Statement
statements
between Flow control: do … loopdo Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Flow control: do … looploop.

When Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop is entered Operators: Make Identifier "@"at Flow control: do … loopdo nothing special happens. But when Flow control: if … then
Flow control: try … then
the
program execution reaches Flow control: do … looploop, Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
program jumps back to Flow control: if … then
Flow control: try … then
the
matching Flow control: do … loopdo Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
. do-loops can be nested to any level.

e.g.:

Instructions: var
How does VScript::Value() work?: Var*&
var
i=1; Flow control: do … loopdo; Instructions: putput i; Flow control: whilewhile i<10; i++; Flow control: do … looploop;

while

Flow control: do … loopdo
    <statements>
    Flow control: whilewhile <condition>
    <statements>
Flow control: do … looploop

Conditionally leave Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop. Flow control: if … then
Flow control: try … then
The
Flow controlcondition must be a numeric Glossary: Valuevalue. Flow control: if … then
Flow control: if … then
If the
<condition> is false (==0) Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop is aborted Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
program execution resumes behind Flow control: do … looploop.

e.g.

Instructions: var
How does VScript::Value() work?: Var*&
var
d = List functions: dir
Instructions: dir
Shell Immediate Commands: dir
dir
(".") Instructions: putput " current directory contents: ", Constants: nlnl Instructions: var
How does VScript::Value() work?: Var*&
var
i=0 Flow control: do … loopdo Flow control: whilewhile i <= Numeric functions: countcount d put d.dir: fnamefname, Constants: nlnl Flow control: do … looploop

until

Flow control: do … loopdo
    <statements>
    Flow control: untiluntil <condition>
    <statements>
Flow control: do … looploop

Conditionally leave Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop. Flow control: if … then
Flow control: try … then
The
Flow controlcondition must be a numeric Glossary: Valuevalue. Flow control: if … then
Flow control: if … then
If the
<condition> is true (!=0) Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop is aborted Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
program execution resumes behind Flow control: do … looploop. Tis is just Flow control: if … then
Flow control: try … then
the
same as Flow control: whilewhile, except with reverted Flow controlcondition.

e.g.

Flow control: do … loopdo
    Instructions: var
How does VScript::Value() work?: Var*&
var
n="" Instructions: putput #stdin, "gimme a Glossary: number, num_valnumber: " Instructions: getget n Flow control: untiluntil n=="" // break from Flow control: do … looploop n = Numeric functions: intint(Functions with varying return types: eval
Instructions: eval
eval
(n)) Instructions: var
How does VScript::Value() work?: Var*&
var
a = 1 Flow control: do … loopdo Flow control: whilewhile (a+=2) <= Numeric functions: sqrtsqrt(n) Flow control: untiluntil Numeric functions: fractfract(n/a) == 0 Flow control: do … looploop Flow control: if … thenif a > Numeric functions: sqrtsqrt(n) Instructions: putput " is prime", Constants: nlnl Flow control: if … then
Flow control: try … then
else
Instructions: putput " = ", a, " * ", n/a, Constants: nlnl Flow control: if … then
Flow control: try … then
then
Flow control: do … looploop

exit

Flow control: do … loopdo
    <statements>
    Flow control: exit
Shell Immediate Commands: exit, quit, end
exit
<statements> Flow control: do … looploop

Unconditionally leave Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop. Flow control: if … then
Flow control: try … then
The
program execution resumes behind Flow control: do … looploop. Since it makes no sense otherwise, Flow control: exit
Shell Immediate Commands: exit, quit, end
exit
is most likely within a conditional Flow controlbranch between Flow control: if … thenif 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
.

e.g.:

Instructions: var
How does VScript::Value() work?: Var*&
var
i=1 Flow control: do … loopdo Flow control: if … thenif i>100 Flow control: exit
Shell Immediate Commands: exit, quit, end
exit
Flow control: if … then
Flow control: try … then
then
i+=i Flow control: do … looploop Instructions: putput "i = ", i, Constants: nlnl

next

Flow control: do … loopdo
    <statements>
    Flow control: nextnext
    <statements>
Flow control: do … looploop

Jump back to Flow control: do … loopdo Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
restart execution of Flow control: if … then
Flow control: try … then
the
Flow control: do … looploop. List functions: thisThis is just what Flow control: do … looploop Flow control: do … loopdoes, Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
since it would make no sense otherwise, Flow control: nextnext is most likely within a conditional Flow controlbranch between Flow control: if … thenif 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
.

e.g.

Instructions: var
How does VScript::Value() work?: Var*&
var
i=1 Flow control: do … loopdo i+=i Flow control: if … thenif i<100 Flow control: nextnext Flow control: if … then
Flow control: try … then
then
Flow control: exit
Shell Immediate Commands: exit, quit, end
exit
Numeric functions: log
Numeric functions: loge
Instructions: log
log
"never seen" Flow control: do … looploop Instructions: putput "i = ", i, Constants: nlnl

end

Flow control: end
Shell Immediate Commands: exit, quit, end
end
Flow control: end
Shell Immediate Commands: exit, quit, end
end
0 Flow control: end
Shell Immediate Commands: exit, quit, end
end
1 Flow control: end
Shell Immediate Commands: exit, quit, end
end
<value>

Flow control: end
Shell Immediate Commands: exit, quit, end
End
of Example Scripts: CGI Scripts
Example Scripts: Scripts
script
optionally returning a Glossary: Valuevalue.

Flow control: whileWhile Flow control: returnreturn, when executed in a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
, will only Flow control: returnreturn from Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
, Flow control: end
Shell Immediate Commands: exit, quit, end
end
allways Flow control: exit
Shell Immediate Commands: exit, quit, end
exits
from Flow control: if … then
Flow control: try … then
the
whole Example Scripts: CGI Scripts
Example Scripts: Scripts
script
.

Flow control: end
Shell Immediate Commands: exit, quit, end
end
may optionall Flow control: returnreturn a Shell Scripts: Return values
Appendix: Return values
return value
. Whether it is expected to Flow control: do … loopdo so Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
which Glossary: Valuevalues are acceptable depends on Flow control: if … then
Flow control: try … then
the
invocation of Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
.

if … then

Flow control: if … thenif <condition>
    <statements>
Flow control: if … then
Flow control: try … then
then
Flow control: if … thenif <condition>
    <statements>
Flow control: if … then
Flow control: try … then
else
<statements> Flow control: if … then
Flow control: try … then
then
Flow control: if … thenif <condition>
    <statements>
Flow control: if … thenelif <condition>
    <statements>   
[ Flow control: if … thenelif <condition>
    <statements> … ]
Flow control: if … then
Flow control: try … then
else
<statements> Flow control: if … then
Flow control: try … then
then

Execute <statements> only Flow control: if … then
Flow control: if … then
if the
<condition> is true.

All Flow controlconditions must be a numeric Glossary: Valuevalues Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
are considered 'true' Flow control: if … thenif they are non-zero.

Flow control: if … then
Flow control: if … then
If the
Flow controlcondition is true, Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Statements
Glossary: Statement
statements
in Flow control: if … then
Flow control: try … then
the
following Flow controlbranch are executed 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
program finally jumps to Flow control: if … then
Flow control: try … then
the
Flow control: if … then
Flow control: try … then
then
Vipsi command syntax: Statements
Glossary: Statement
statement
, skipping all optionally present Flow control: if … thenelif 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
else
Flow controlbranches.

Flow control: if … then
Flow control: if … then
If the
Flow controlcondition is false, Flow control: if … then
Flow control: try … then
then
List functions: thisthis Flow controlbranch is skipped, Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
all optionally present Flow control: if … thenelif Flow controlconditions are tested in order. Flow control: if … then
Flow control: try … then
The
Flow controlbranch of Flow control: if … then
Flow control: try … then
the
first Flow control: if … thenelif Flow controlcondition which is true is executed 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
program finally jumps to Flow control: if … then
Flow control: try … then
the
Flow control: if … then
Flow control: try … then
then
Vipsi command syntax: Statements
Glossary: Statement
statement
, skipping all other Flow control: if … thenelif 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
else
Flow controlbranches.

Flow control: if … thenIf all Flow controlconditions fail, Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
final Flow control: if … then
Flow control: try … then
else
Flow controlbranch is executed, Flow control: if … thenif present. Flow control: if … thenIf no Flow control: if … then
Flow control: try … then
else
Flow controlbranch is present, Flow control: if … then
Flow control: try … then
then
actually no Vipsi command syntax: Statements
Glossary: Statement
statements
between Flow control: if … thenif 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
except for Flow control: if … then
Flow control: try … then
the
Flow control: if … thenelif Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
are executed Operators: Make Identifier "@"at all.

e.g.

Flow control: if … thenif (a>b) Flow control: returnreturn a; Flow control: if … then
Flow control: try … then
else
Flow control: returnreturn b; Flow control: if … then
Flow control: try … then
then
; Flow control: if … thenif a<0 Instructions: putput "a is smaller than zero" Flow control: if … thenelif a==0 Instructions: putput "a is exactly zero" Flow control: if … thenelif a>0 Instructions: putput "a is greater than zero" Flow control: if … then
Flow control: try … then
else
Instructions: putput "you caught a NaN" Flow control: if … then
Flow control: try … then
then

return

Flow control: returnreturn
Flow control: returnreturn <value>

Flow control: end
Shell Immediate Commands: exit, quit, end
End
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
optionally Flow control: returnreturn a result Glossary: Valuevalue.

Flow control: if … thenIf a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Flow control: returnreturns a Glossary: Valuevalue, it should be called like a Vipsi command syntax: Functions
Functions
Glossary: Function
function
. Flow control: if … then
Flow control: try … then
The
result Glossary: Valuevalue may be any Data Types
Invariants: Data types
data type
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
of any size.

Flow control: if … thenIf a Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Flow control: returnreturns no Glossary: Valuevalue, it should be called Operators: Make Identifier "@"at Flow control: if … then
Flow control: try … then
the
place of an Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
.

Flow control: if … thenIf Flow control: returnreturn is executed on 'ground level', that is, outside any Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
, it Flow control: returnreturns from Flow control: if … then
Flow control: try … then
the
current Example Scripts: CGI Scripts
Example Scripts: Scripts
script
. Flow control: if … then
Flow control: try … then
Then
Flow control: returnreturn behaves just like Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instruction
Flow control: end
Shell Immediate Commands: exit, quit, end
end
. Flow control: if … then
Flow control: try … then
The
possible Shell Scripts: Return values
Appendix: Return values
return value
depends on Flow control: if … then
Flow control: try … then
the
invocation of Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
:

e.g.:

Instructions: procproc Geomed(a,b) { Flow control: returnreturn Numeric functions: sqrtsqrt(a*b); }

Instructions: procproc Check(t) { Flow control: if … thenif Numeric functions: istextistext(t) Flow control: returnreturn; Flow control: if … then
Flow control: try … then
else
Instructions: putput "no Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
:",t; Flow control: if … then
Flow control: try … then
then
}

try … then

Flow control: try … thentry
    <statements>
Flow control: if … then
Flow control: try … then
then
Flow control: try … thentry
    <statements>
Flow control: if … then
Flow control: try … then
else
<statements> Flow control: if … then
Flow control: try … then
then

Execute Vipsi command syntax: Statements
Glossary: Statement
statements
with a "safety net".

Flow control: if … thenIf a runtime error occurs, Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
program is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
aborted with an error message. Instead Flow control: if … then
Flow control: try … then
the
program execution resumes after Flow control: if … then
Flow control: try … then
then
Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
, Flow control: if … thenif present, Operators: Make Identifier "@"at your error handler after Flow control: if … then
Flow control: try … then
else
.

In case of an error Flow control: if … then
Flow control: try … then
the
Glossary: Variable, var_refvariable errorstr is created (Flow control: if … thenif it Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
already Numeric functions: existsexists) Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
contains Flow control: if … then
Flow control: try … then
the
error message.

Your error handler Instructions: getgets also called Flow control: if … then
Flow control: if … then
if the
error occurs deep inside some nested Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
procedure
Functions with varying return types: call
Instructions: call
call
, Flow control: if … thenif no other error handler catches it before you.

e.g.:

Flow control: try … thentry
    Instructions: openinopenin #4, "that damn ol' Text functions: file
Instructions: file
file
" Flow control: if … then
Flow control: try … then
else
Numeric functions: log
Numeric functions: loge
Instructions: log
log
"failed: ", errorstr, Constants: nlnl Flow control: if … then
Flow control: try … then
then

Valid HTML   Valid CSS