|
With all Vipsi command syntax: Functions Functions Glossary: Functionfunctions which take exactly one Vipsi command syntax: Arguments Glossary: Argumentsargument, Flow control: if … then Flow control: try … thenthe Separators: Round brackets "( … )"parenthesis may be omitted, Flow control: if … then Flow control: if … thenif the Vipsi command syntax: Arguments Glossary: Argumentsargument is a simple Glossary: Valuevalue Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and no Vipsi command syntax: Expressions Glossary: Expressionexpression with Vipsi command syntax: Operators Operators Glossary: Operatoroperators. Flow control: if … then Flow control: if … thenIf the Vipsi command syntax: Arguments Glossary: Argumentsargument is a Vipsi command syntax: Expressions Glossary: Expressionexpression, Flow control: if … then Flow control: try … thenthen you must use Separators: Round brackets "( … )"parenthesis.
Numeric functions: sinsin 2*Constants: pipi == Numeric functions: sinsin(2) * Constants: pipi != Numeric functions: sinsin(2*Constants: pipi)
Flow control: if … thenIf a Vipsi command syntax: Statements Glossary: Statementstatement starts with '{' List functions: thisthis is Operators: Bitwise Not "~" Operators: Boolean Negation "!"not recognized as a Data Types: Lists and arrays Glossary: list, list_vallist, but as start of a List functions: localslocal context instead. It is very unlikely for a normal program that a Vipsi command syntax: Statements Glossary: Statementstatement starts with a Literals: List literals Lists and arrays: List literalslist literal. Maybe it happens to you sometime on Flow control: if … then Flow control: try … thenthe vipsi shell command line:
vipsi> { 1, 2, 3 }
***** numeric Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Glossary: text, text_valtext value expected
vipsi> { 1, 2, 3 }
Flow control: if … thenIf you want to print it from Flow control: if … then Flow control: try … thenthe command line, use Instructions: putput, Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or encloce it in Separators: Round brackets "( … )"parenthesis:
vipsi> Instructions: putput {1,2,3} = { 1, 2, 3 }
vipsi> ({1,2,3}) = { 1, 2, 3 }
vipsi>
Flow control: if … thenIf you want to print Flow control: if … then Flow control: try … thenthe Data Types: Lists and arrays Glossary: list, list_vallist from a Example Scripts: CGI Scripts Example Scripts: Scriptsscript, you must use Instructions: putput anyway Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and Flow control: if … then Flow control: try … thenthe problem Flow control: do … loopdoes Operators: Bitwise Not "~" Operators: Boolean Negation "!"not occur:
Instructions: putput { 1,2,3 }
Flow control: if … thenIf a Vipsi command syntax: Statements Glossary: Statementstatement after a Vipsi command syntax: Statements Glossary: Statementstatement with Vipsi command syntax: Arguments Glossary: Argumentsarguments starts with '-', '+' Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or '%' Flow control: if … then Flow control: try … thenthen List functions: thisthis character is Operators: Bitwise Not "~" Operators: Boolean Negation "!"not recognized as a Glossary: number, num_valnumber Numeric functions: signsign start of a Integer numbers: Binary Floating point: Binary Text functions: binstrbinary Literals: Number literals Numbers: Number literalsnumber literal but interpreted as Vipsi command syntax: Operators Operators Glossary: Operatoroperator Operators: Subtract "-"minus, Operators: Add "+"plus Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Operators: Remainder with Variable "%=" Operators: Remainder "%"remainder linking it to Flow control: if … then Flow control: try … thenthe last Vipsi command syntax: Arguments Glossary: Argumentsargument of Flow control: if … then Flow control: try … thenthe previous Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction.
List functions: thisThis will almost certainly happen only in broken code.
In a sane program, each Vipsi command syntax: Statements Glossary: Statementstatement starts with an Vipsi command syntax: Identifiers (names) Data Types: Identifiers, names Operators: Make Identifier "@" Glossary: Name, Identifieridentifier Vipsi command syntax: Identifiers (names) Data Types: Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername:
Flow control: if … thenIf a Vipsi command syntax: Statements Glossary: Statementstatement starts with '%', '+' Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or '-', Flow control: if … then Flow control: try … thenthen List functions: thisthis Vipsi command syntax: Expressions Glossary: Expressionexpression will Flow control: returnreturn a result Glossary: Valuevalue. In a Example Scripts: CGI Scripts Example Scripts: Scriptsscript List functions: thisthis result Glossary: Valuevalue will be discarded. I can hardly think of any useful code, with a Vipsi command syntax: Statements Glossary: Statementstatement beginning with a numeric Glossary: Valuevalue. Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"And all examples i can imagine are lunatic Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or malicious.
#!/usr/bin/vipsi
// very broken:
+123 Instructions: var How does VScript::Value() work?: Var*&var a=0
-123 Instructions: var How does VScript::Value() work?: Var*&var b=0
+123 Instructions: var How does VScript::Value() work?: Var*&var c=0
%011
Instructions: putput Constants: nlnl, "-> ", a, Constants: tabtab, b, Constants: tabtab, c, Constants: nlnl
// very insane:
Instructions: procproc mySideEffect(a){ Instructions: putput a; Flow control: returnreturn a }
Instructions: putput 222
+mySideEffect(77)
Even in Flow control: if … then Flow control: try … thenthe shell Flow control: if … thenif you want to print Flow control: if … then Flow control: try … thenthe result of an Vipsi command syntax: Expressions Glossary: Expressionexpression, Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and Flow control: if … then Flow control: try … thenthe Vipsi command syntax: Expressions Glossary: Expressionexpression starts with a Literals: Number literals Numbers: Number literalsnumber literal which starts with '%', '+' Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or '-', List functions: thisthis is no problem, because you'll rarely append such a calculation after another Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction with Vipsi command syntax: Arguments Glossary: Argumentsarguments. List functions: thisThis would look pretty insane:
vipsi> Instructions: putput 100 -123 -23
vipsi> Instructions: putput 100 +123 223
vipsi> Instructions: putput 100 %011 1
vipsi>
Flow control: if … thenIf you successfully construct a case where it matters, use Instructions: putput Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or enclose it in Separators: Round brackets "( … )"parenthesis:
vipsi> Flow control: if … then Flow control: if … thenif 1 -123 then /* prints nothing */
vipsi> Flow control: if … thenif 1 Instructions: putput -123 Flow control: if … then Flow control: try … thenthen -123
vipsi> Flow control: if … then Flow control: if … thenif 1 (-123) then -123
vipsi> Flow control: if … then Flow control: if … thenif 1; -123 then -123
vipsi>
These two Vipsi command syntax: Instructions Instructions Glossary: Instructioninstructions are special in Flow control: if … then Flow control: try … thenthe way, that they are Flow control: if … then Flow control: try … thenthe only Vipsi command syntax: Instructions Instructions Glossary: Instructioninstructions which can optionally take no Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or one Vipsi command syntax: Arguments Glossary: Argumentsargument. All other Vipsi command syntax: Instructions Instructions Glossary: Instructioninstructions can take either no Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Operators: Make Identifier "@"at least one Vipsi command syntax: Arguments Glossary: Argumentsargument. List functions: thisThis is important for Flow control: if … then Flow control: try … thenthe parser, because it must know whether Flow control: if … then Flow control: try … thenthe Vipsi command syntax: Expressions Glossary: Expressionexpression after an Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction must be interpretet as an Vipsi command syntax: Arguments Glossary: Argumentsargument to that Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or as a Instructions: newnew Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction, even Flow control: if … thenif it yields a result. Flow control: if … then Flow control: try … thenThe latter case is very common, because Flow control: if … then Flow control: try … thenthe Operators: Assignment "=" Built-in operators: Assignments:assignment Vipsi command syntax: Operators Operators Glossary: Operatoroperators all Flow control: returnreturn Flow control: if … then Flow control: try … thenthe assigned Glossary: Valuevalue (acually a reference to Flow control: if … then Flow control: try … thenthe Glossary: Variable, var_refvariable) as result! Therefore:
Instructions: putput a=22
will Operators: Assignment "="assign 22 to a Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and print Flow control: if … then Flow control: try … thenthe result, which is 22. Flow control: whileWhile
Instructions: putput "x" a=22
will print "x" but Operators: Bitwise Not "~" Operators: Boolean Negation "!"not Flow control: if … then Flow control: try … thenthe result of Flow control: if … then Flow control: try … thenthe Operators: Assignment "=" Built-in operators: Assignments:assignment a=22, because that is a Instructions: newnew Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction. Flow control: if … thenIf you wanted to print both, "x" Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and "22", Flow control: if … then Flow control: try … thenthen you needed to append a=22 with a Separators: Comma ","comma "," to Flow control: if … then Flow control: try … thenthe Vipsi command syntax: Arguments Glossary: Argumentsargument Data Types: Lists and arrays Glossary: list, list_vallist of Instructions: putput.
Additionally, Flow control: if … then Flow control: if … thenif the Flow control: nextnext Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction is self-defined Vipsi command syntax: Procedures Data Types: Procedures Glossary: Procedureprocedure, Flow control: if … then Flow control: try … thenthe parser Flow control: do … loopdoes Operators: Bitwise Not "~" Operators: Boolean Negation "!"not know whether it will Flow control: returnreturn a result Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and assume that it will. List functions: thisThis makes no difference for a Vipsi command syntax: Procedures Data Types: Procedures Glossary: Procedureprocedure written Operators: Make Identifier "@"at Flow control: if … then Flow control: try … thenthe place of an Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction, because either it Flow control: do … loopdoes Operators: Bitwise Not "~" Operators: Boolean Negation "!"not Flow control: returnreturn a result Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Flow control: if … then Flow control: try … thenthe returned result will be discarded. (Operators: Bitwise Not "~" Operators: Boolean Negation "!"note: on Flow control: if … then Flow control: try … thenthe vipsi shell printed for your convenience.)
Therefore Flow control: if … then Flow control: try … thenthe parser has a little problem with Flow control: returnreturn Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Flow control: end Shell Immediate Commands: exit, quit, endend, which may Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or may Operators: Bitwise Not "~" Operators: Boolean Negation "!"not be followed by an Vipsi command syntax: Arguments Glossary: Argumentsargument. How to decide? Flow control: if … then Flow control: try … thenThe stunning fact is, it's Shell Immediate Commands: exit, quit, endquite easy: Because both Vipsi command syntax: Instructions Instructions Glossary: Instructioninstructions break from Flow control: if … then Flow control: try … thenthe program flow, Flow control: if … then Flow control: try … thenthe Flow control: nextnext Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction won't be executed. Therefore in a proper program Flow control: if … then Flow control: try … thenthe Flow control: nextnext Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction can only be a switching Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or terminating Vipsi command syntax: Flow control Flow controlflow control List functions: words Shell Immediate Commands: wordsword: Flow control: if … then Flow control: try … thenelse, Flow control: if … thenelif, Flow control: if … then Flow control: try … thenthen Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Flow control: do … looploop. Every other List functions: words Shell Immediate Commands: wordsword makes no sense. So Flow control: if … then Flow control: try … thenthe Flow control: returnreturn Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and Flow control: end Shell Immediate Commands: exit, quit, endend handler just test, whether Flow control: if … then Flow control: try … thenthe Flow control: nextnext List functions: words Shell Immediate Commands: wordsword is one of those List functions: words Shell Immediate Commands: wordswords (actually they test for 'Invariants: Built-in instructionsbuilt-in instruction returning no Glossary: Valuevalue') Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and Flow control: returnreturns with no result Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or evaluates Flow control: if … then Flow control: try … thenthe following Vipsi command syntax: Expressions Glossary: Expressionexpression.
There is no problem. Except in one situation, which stunningly often happens to me:
When a program fails somehow Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and i debug it, i often Instructions: putput in a Flow control: returnreturn somewhere. Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"And that position, self-evidently is Operators: Bitwise Not "~" Operators: Boolean Negation "!"not before one of Flow control: if … then Flow control: try … thenthe terminating Vipsi command syntax: Flow control Flow controlflow control List functions: words Shell Immediate Commands: wordsword. Frequently enough before a Functions with varying return types: call Instructions: callcall to a self-defined Vipsi command syntax: Procedures Data Types: Procedures Glossary: Procedureprocedure Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and Flow control: if … then Flow control: try … thenthen Flow control: if … then Flow control: try … thenthe Vipsi command syntax: Procedures Data Types: Procedures Glossary: Procedureprocedure Functions with varying return types: call Instructions: callcall after Flow control: if … then Flow control: try … thenthe Flow control: returnreturn unexpectedly Instructions: getgets called before Flow control: returnreturn Flow control: returnreturns, just because Flow control: if … then Flow control: try … thenthe parser assumes that it delivers an Vipsi command syntax: Arguments Glossary: Argumentsargument. Puzzled me sometimes.
From a real-world case:
Instructions: procproc Doit()
{
QuelltextEinlesen()
TagsAbtrennen()
Flow control: returnreturn // <-- inserted for testing
TagsBehandeln()
AnkerErzeugen()
QuerverweiseEinfügen()
BuchNachHtmlKonvertieren()
BuchdateienSchreiben()
}
In Flow control: if … then Flow control: try … thenthe case above Flow control: if … then Flow control: try … thenthe Vipsi command syntax: Procedures Data Types: Procedures Glossary: Procedureprocedure TagsBehandeln() was called despite Flow control: if … then Flow control: try … thenthe Flow control: returnreturn in front of it. List functions: thisThis is, as you can see, because i never terminate my Vipsi command syntax: Instructions Instructions Glossary: Instructioninstructions with Separators: Semicolon ";"semicolons ";" as i should Flow control: do … loopdo. Just adding a Separators: Semicolon ";"semicolon ";" after Flow control: if … then Flow control: try … thenthe Flow control: returnreturn did remedy Flow control: if … then Flow control: try … thenthe problem.
Ever wondered why there is 1 subtracted when storing Flow control: if … then Flow control: try … thenthe Numeric functions: countcount of List functions: globals Shell Immediate Commands: globalsglobal Glossary: Variable, var_refvariables into a Glossary: Variable, var_refvariable, which frequently happens to be named argc?
It's no bug, work-around Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or even an ambiguity, it's just that Numeric functions: countcount List functions: globals Shell Immediate Commands: globalsglobals is executed after Instructions: var How does VScript::Value() work?: Var*&var argc, Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and therefore Flow control: if … then Flow control: try … thenthe Glossary: Variable, var_refvariable argc already Numeric functions: existsexists when Numeric functions: countcount Numeric functions: countcounts Flow control: if … then Flow control: try … thenthe Glossary: number, num_valnumber of List functions: globals Shell Immediate Commands: globalsglobal Glossary: Variable, var_refvariables. So Flow control: if … then Flow control: try … thenthe Numeric functions: countcount will Functions with varying return types: include Instructions: includeinclude Glossary: Variable, var_refvariable argc Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and we Operators: Subtract from Variable "-=" Operators: Subtract "-"subtract 1 for that fact.
Just to Operators: Bitwise Not "~" Operators: Boolean Negation "!"note it somewhere.
|