vipsi - the friendly vip script interpreter

Example Scripts

Libraries

BOOK: Create Online Books

Listing of automate.vs

#!/usr/local/bin/vipsi


/* ---- command line Vipsi command syntax: Arguments
Glossary: Arguments
arguments
? ------------------------------- */ Instructions: var
How does VScript::Value() work?: Var*&
var
verbose = 0 Instructions: var
How does VScript::Value() work?: Var*&
var
i = 0 Flow control: do … loopdo Flow control: whilewhile ++i <= Numeric functions: countcount List functions: globals
Shell Immediate Commands: globals
globals
&& Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
List functions: globals
Shell Immediate Commands: globals
globals
[i]=="" Flow control: if … thenif List functions: globals
Shell Immediate Commands: globals
globals
[i]=="-v" Instructions: deldel List functions: globals
Shell Immediate Commands: globals
globals
[i--] verbose=1 Flow control: nextnext Flow control: if … then
Flow control: try … then
then
Flow control: do … looploop Functions with varying return types: include
Instructions: include
include
"/usr/local/lib/vipsi/BOOK.vl" SplitFileSize = 30000 // adjust TargetDir = "../" // adjust /* -------------------------------------------------------------------- List functions: thisThis Text functions: file
Instructions: file
file
already contains some sophisticated customizations: Template.Page = «...» replaced html page template Tags.Functions with varying return types: include
Instructions: include
include
added a tag for source Text functions: file
Instructions: file
file
inclusion as <pre> Tags.shell added a tag for mocked-up vipsi shell examples -------------------------------------------------------------------- */ /* Instructions: newnew Tag "shell": input lines: shell i> what Flow control: if … then
Flow control: try … then
the
user typed o> output more output e> error message i> <> i> some List functions: words
Shell Immediate Commands: words
words
<> i> Instructions: editedit<x>line generated html: <pre class=out> vipsi> <span class=in>what Flow control: if … then
Flow control: try … then
the
user typed</span> output more output <span class=err>error message</span> vipsi> <span class=crsr> </span> vipsi> <span class=in>some List functions: words
Shell Immediate Commands: words
words
</span><span class=crsr> </span> vipsi> <span class=in>Instructions: editedit<span class=crsr>x</span>line</span> </pre> Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
note
: Bei Aufruf von Tags.shell.Instructions: readRead(i) sind schon alle Zeilen verschmolzen */ Instructions: procproc r(i) { Instructions: renamerename Buch[i] = "pre" // --> default Instructions: writewrite handler w0() Buch[i] ##= { Class="out" } // --> dflt Instructions: writewrite handler will Operators: Add to Variable "+="
Operators: Add "+"
add
css Developer Documentation: Class Varclass var Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Constants: nlnl#Buch[i].Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
#Constants: nlnl, a,e,e2 // "<>" -> cursor blob Flow control: do … loopdo a = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"<>") // <> anywhere: cursor Flow control: whilewhile a Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a-1]#"<span class=crsr> </span>"#Text[a+2 to] Flow control: do … looploop // "<X>" -> cursor über Zeichen "X" a=0 Flow control: do … loopdo a = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"<",a+1) Flow control: whilewhile a Flow control: if … thenif Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[a+2]!=">" Flow control: nextnext Flow control: if … then
Flow control: try … then
then
Flow control: if … thenif Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"</"#Text[a+1]#">",a+3) Flow control: nextnext Flow control: if … then
Flow control: try … then
then
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a-1] # "<span class=crsr>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[a+1] # "</span>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[a+3 to] a+=20 Flow control: do … looploop // "e> " am Zeilenanfang: Error Message Flow control: do … loopdo a = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"\ne> ") Flow control: whilewhile a e = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,Constants: nlnl,a+3) Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a]#"<span class=err>"#Text[a+4 to e-1]#"</span>"#Text[e to] Flow control: do … looploop // "o> " am Zeilenanfang: text to Constants: stdoutstdout. no formatting ((whole <pre> is class=out)) Flow control: do … loopdo a = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"\no> ") Flow control: whilewhile a Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a]#Text[a+4 to] Flow control: do … looploop Flow control: do … loopdo a = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"\no>") Flow control: whilewhile a Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a]#Text[a+3 to] Flow control: do … looploop // "i> " am Zeilenanfang: vipsi> prompt und Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
to Constants: stdinstdin. Prüfe auf folgendes "o> " Flow control: do … loopdo a = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"\ni> ") Flow control: whilewhile a e = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,Constants: nlnl,a+3) e2 = Numeric functions: findfind(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
,"o> ",a+3) Flow control: if … thenif (e2&&e2<e) // "o> " Numeric functions: existsexists Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a] # "vipsi> <span class=in>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[a+4 to e2-1] # "</span>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[e2+3 to] Flow control: if … then
Flow control: try … then
else
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[to a] # "vipsi> <span class=in>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[a+4 to e-1] # "</span>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[e to] Flow control: if … then
Flow control: try … then
then
Flow control: do … looploop Buch[i].Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
[2 to Numeric functions: countcount Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
-1] Flow control: returnreturn i+1 } Instructions: var
How does VScript::Value() work?: Var*&
var
Tags.@"shell" = { Class='PRE', Instructions: readRead=r, Instructions: writeWrite=w0, Where=" h1 h2 h3 h4 h5 h6 " } /* Instructions: newnew Tag "Functions with varying return types: include
Instructions: include
include
": Functions with varying return types: include
Instructions: include
include
Text functions: file
Instructions: file
file
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
place it in <pre> tags since lots of those Text functions: file
Instructions: file
files
are Modes of Operation: CGI Scripts
Example Scripts: CGI Scripts
cgi scripts
, we have Flow control: if … then
Flow control: try … then
the
problem with Flow control: if … then
Flow control: try … then
the
html tags in Flow control: if … then
Flow control: try … then
the
source. therefore Flow control: if … then
Flow control: try … then
the
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
is converted to html in before. Flow control: if … then
Flow control: try … then
The
html Text functions: convert
Instructions: convert
converter
HTML.BuchNachHtmlKonvertieren() is smart enough to detect Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
preserve most html tags. */ Instructions: procproc r(i) { Flow control: try … thentry Instructions: var
How does VScript::Value() work?: Var*&
var
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Text functions: file
Instructions: file
file
( Buch[i].Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
) Flow control: if … then
Flow control: try … then
else
Numeric functions: log
Numeric functions: loge
Instructions: log
log
Constants: nlnl, «Functions with varying return types: include
Instructions: include
include
Text functions: file
Instructions: file
file
», Buch[i].Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
, « failed: ignored.» Instructions: deldel Buch[i] Flow control: returnreturn i Flow control: if … then
Flow control: try … then
then
Text functions: convert
Instructions: convert
convert
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
from utf8 Text functions: convert
Instructions: convert
convert
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
from @("Constants: tabtab"#TabWidth) Text functions: convert
Instructions: convert
convert
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
to html Buch[i].Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
= Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
TEXT
.CropSpaces(Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
Text
) Instructions: renamerename Buch[i] = "pre" // --> default Instructions: writewrite handler w0() // will create a <pre> tag Buch[i] ##= { Class="src" } // --> css Flow control: returnreturn i+1 } Instructions: var
How does VScript::Value() work?: Var*&
var
Tags.@"Functions with varying return types: include
Instructions: include
include
" = { Class='DEF', Instructions: readRead=r, Instructions: writeWrite=w0, Where=" h1 h2 h3 h4 h5 " } /* Template.Numeric functions: indexIndex für die Startseite Template.List functions: split
Instructions: split
Split
für die TOC-Seite von gesplitteten Kapiteln Template.Page für normale Seiten */ Template.Page = «<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <META http-equiv=Content-Type content="Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html; charset=UTF-8"> <title>%%TITLE%%</title> <meta Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
="author" content="kio@little-bat.de"> <meta Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
="copyright" content="1998-2004 Kio (Günter Woigk)"> <meta Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
="robots" content="Numeric functions: indexindex,follow"> <meta Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
="keywords" content="%%KEYWORDS%%"> <meta Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
="description" content="%%TITLE%% ((online book))"> <Text functions: link
Instructions: link
link
rel="stylesheet" type="Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/css" href="b/all.css"> <Example Scripts: CGI Scripts
Example Scripts: Scripts
script
type="Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/javascript"> Instructions: var
How does VScript::Value() work?: Var*&
var
o=""; Vipsi command syntax: Functions
Functions
Glossary: Function
function
S(n) { H(); document.getElementById(n).style.visibility='visible'; o=n; } Vipsi command syntax: Functions
Functions
Glossary: Function
function
H() { Flow control: if … thenif(o!="") document.getElementById(o).style.visibility='hidden'; o=""; } </Example Scripts: CGI Scripts
Example Scripts: Scripts
script
> </head><body id="A"> %%HEADLINE0%%%%HEADLINE1%% <p class="pglinks_o"><a href="%%PREV%%">[&lt;prev]</a> &nbsp; &nbsp; <a href="%%Flow control: nextNEXT%%">[Flow control: nextnext&gt;]</a></p> <table width="100%"><tr><td width="10%"></td><td width=500> %%HEADLINE2%%%%HEADLINE3%%%%HEADLINE4%%%%HEADLINE5%%%%HEADLINE6%% %%TOC%%%%BODY%% </td><td width="10%"></td></tr></table> <p class="pglinks_u"><a href="%%PREV%%">[&lt;prev]</a> &nbsp; <a href="#A">[top]</a> &nbsp; <a href="%%Flow control: nextNEXT%%">[Flow control: nextnext&gt;]</a></p> <p class="foot"><a href="http://validator.w3.org/check/referer"> <img border=0 src="b/html401.png" alt="Valid HTML" height=31 width=88></a> &nbsp; <img border=0 src="b/css.png" alt="Valid CSS" height=31 width=88></p> </body></html> » Doit() Instructions: putput Constants: nlnl,Constants: nlnl,"--- finished ---",Constants: nlnl,Constants: nlnl Flow control: end
Shell Immediate Commands: exit, quit, end
end
0

Valid HTML   Valid CSS