|
#!/usr/local/bin/vipsi
/* ---- command line Vipsi command syntax: Arguments Glossary: Argumentsarguments ? -------------------------------
*/
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: globalsglobals && Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername List functions: globals Shell Immediate Commands: globalsglobals[i]==""
Flow control: if … thenif List functions: globals Shell Immediate Commands: globalsglobals[i]=="-v" Instructions: deldel List functions: globals Shell Immediate Commands: globalsglobals[i--] verbose=1 Flow control: nextnext Flow control: if … then Flow control: try … thenthen
Flow control: do … looploop
Functions with varying return types: include Instructions: includeinclude "/usr/local/lib/vipsi/BOOK.vl"
SplitFileSize = 30000 // adjust
TargetDir = "../" // adjust
/* --------------------------------------------------------------------
List functions: thisThis Text functions: file Instructions: filefile already contains some sophisticated customizations:
Template.Page = «...» replaced html page template
Tags.Functions with varying return types: include Instructions: includeinclude added a tag for source Text functions: file Instructions: filefile 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 … thenthe user typed o> output
more output
e> error message
i> <>
i> some List functions: words Shell Immediate Commands: wordswords<>
i> Instructions: editedit<x>line
generated html:
<pre class=out>
vipsi> <span class=in>what Flow control: if … then Flow control: try … thenthe 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: wordswords</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_valText = Constants: nlnl#Buch[i].Data Types: Text Item selector "[]": Text Glossary: text, text_valText#Constants: nlnl, a,e,e2
// "<>" -> cursor blob
Flow control: do … loopdo
a = Numeric functions: findfind(Data Types: Text Item selector "[]": Text Glossary: text, text_valText,"<>") // <> anywhere: cursor
Flow control: whilewhile a
Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[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_valText,"<",a+1)
Flow control: whilewhile a
Flow control: if … thenif Data Types: Text Item selector "[]": Text Glossary: text, text_valText[a+2]!=">" Flow control: nextnext Flow control: if … then Flow control: try … thenthen
Flow control: if … thenif Numeric functions: findfind(Data Types: Text Item selector "[]": Text Glossary: text, text_valText,"</"#Text[a+1]#">",a+3) Flow control: nextnext Flow control: if … then Flow control: try … thenthen
Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[to a-1] # "<span class=crsr>" # Data Types: Text Item selector "[]": Text Glossary: text, text_valText[a+1]
# "</span>" # Data Types: Text Item selector "[]": Text Glossary: text, text_valText[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_valText,"\ne> ")
Flow control: whilewhile a
e = Numeric functions: findfind(Data Types: Text Item selector "[]": Text Glossary: text, text_valText,Constants: nlnl,a+3)
Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[to a]#"<span class=err>"#Text[a+4 to e-1]#"</span>"#Text[e to]
Flow control: do … looploop
// "o> " am Zeilenanfang: Data Types: Text Item selector "[]": Text Glossary: text, text_valtext 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_valText,"\no> ") Flow control: whilewhile a Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[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_valText,"\no>") Flow control: whilewhile a Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[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_valtext 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_valText,"\ni> ")
Flow control: whilewhile a
e = Numeric functions: findfind(Data Types: Text Item selector "[]": Text Glossary: text, text_valText,Constants: nlnl,a+3)
e2 = Numeric functions: findfind(Data Types: Text Item selector "[]": Text Glossary: text, text_valText,"o> ",a+3)
Flow control: if … thenif (e2&&e2<e) // "o> " Numeric functions: existsexists
Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[to a] # "vipsi> <span class=in>" # Data Types: Text Item selector "[]": Text Glossary: text, text_valText[a+4 to e2-1]
# "</span>" # Data Types: Text Item selector "[]": Text Glossary: text, text_valText[e2+3 to]
Flow control: if … then Flow control: try … thenelse
Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[to a] # "vipsi> <span class=in>" # Data Types: Text Item selector "[]": Text Glossary: text, text_valText[a+4 to e-1]
# "</span>" # Data Types: Text Item selector "[]": Text Glossary: text, text_valText[e to]
Flow control: if … then Flow control: try … thenthen
Flow control: do … looploop
Buch[i].Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valText[2 to Numeric functions: countcount Data Types: Text Item selector "[]": Text Glossary: text, text_valText -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: includeinclude": Functions with varying return types: include Instructions: includeinclude Text functions: file Instructions: filefile 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: filefiles are Modes of Operation: CGI Scripts Example Scripts: CGI Scriptscgi scripts, we have Flow control: if … then Flow control: try … thenthe
problem with Flow control: if … then Flow control: try … thenthe html tags in Flow control: if … then Flow control: try … thenthe source.
therefore Flow control: if … then Flow control: try … thenthe Data Types: Text Item selector "[]": Text Glossary: text, text_valtext is converted to html in before.
Flow control: if … then Flow control: try … thenThe html Text functions: convert Instructions: convertconverter 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_valText = Text functions: file Instructions: filefile( Buch[i].Data Types: Text Item selector "[]": Text Glossary: text, text_valText )
Flow control: if … then Flow control: try … thenelse
Numeric functions: log Numeric functions: loge Instructions: loglog Constants: nlnl, «Functions with varying return types: include Instructions: includeinclude Text functions: file Instructions: filefile », Buch[i].Data Types: Text Item selector "[]": Text Glossary: text, text_valText, « failed: ignored.»
Instructions: deldel Buch[i] Flow control: returnreturn i
Flow control: if … then Flow control: try … thenthen
Text functions: convert Instructions: convertconvert Data Types: Text Item selector "[]": Text Glossary: text, text_valText from utf8
Text functions: convert Instructions: convertconvert Data Types: Text Item selector "[]": Text Glossary: text, text_valText from @("Constants: tabtab"#TabWidth)
Text functions: convert Instructions: convertconvert Data Types: Text Item selector "[]": Text Glossary: text, text_valText to html
Buch[i].Data Types: Text Item selector "[]": Text Glossary: text, text_valText = Data Types: Text Item selector "[]": Text Glossary: text, text_valTEXT.CropSpaces(Data Types: Text Item selector "[]": Text Glossary: text, text_valText)
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: includeinclude" = { 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: splitSplit 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_valtext/html; charset=UTF-8">
<title>%%TITLE%%</title>
<meta Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername="author" content="kio@little-bat.de">
<meta Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername="copyright" content="1998-2004 Kio (Günter Woigk)">
<meta Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername="robots" content="Numeric functions: indexindex,follow">
<meta Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername="keywords" content="%%KEYWORDS%%">
<meta Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername="description" content="%%TITLE%% ((online book))">
<Text functions: link Instructions: linklink rel="stylesheet" type="Data Types: Text Item selector "[]": Text Glossary: text, text_valtext/css" href="b/all.css">
<Example Scripts: CGI Scripts Example Scripts: Scriptsscript type="Data Types: Text Item selector "[]": Text Glossary: text, text_valtext/javascript">
Instructions: var How does VScript::Value() work?: Var*&var o="";
Vipsi command syntax: Functions Functions Glossary: Functionfunction S(n)
{ H(); document.getElementById(n).style.visibility='visible'; o=n; }
Vipsi command syntax: Functions Functions Glossary: Functionfunction H()
{ Flow control: if … thenif(o!="") document.getElementById(o).style.visibility='hidden'; o=""; }
</Example Scripts: CGI Scripts Example Scripts: Scriptsscript>
</head><body id="A">
%%HEADLINE0%%%%HEADLINE1%%
<p class="pglinks_o"><a href="%%PREV%%">[<prev]</a>
<a href="%%Flow control: nextNEXT%%">[Flow control: nextnext>]</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%%">[<prev]</a>
<a href="#A">[top]</a> <a href="%%Flow control: nextNEXT%%">[Flow control: nextnext>]</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>
<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, endend 0
| |