1. Relational Database Application
1.1. Dissimilarity from SQL2. Object-oriented Database Application
1.2. Declaring database
$base S =; $base S ~; = $base S; ~ $base S; $base S; $S; $S*
1.3. Creating table relations
R (A1, ...); R:r (A1:a1, ...); [E1, ...]; S*; #n
1.4. Selecting table relations
= E; = A:a; = R:r (A1:a1, ...); = [E1 =/~/, ...]; = A: a^b; *S; *S*
1.5. Printing database contents
$printX($file "F", Q1, ...); $number(...); $one(...); = ; =S; ={S}; = *
1.6. Updating relation
=E = (A1:a1, ...); E ~ (A1:a1, ...); R: #
1.7. Coping and deleting relation
R0 =/~ R1; R: [r0 =/~ r1]; R:r ~ ( ); R:r ~
1.8. Exporting and importing table data
$readTable($file "F", N0, N1, ...); $printTable($file "F", Q, A0, A1, ...)
1.9. Quoting and numbering
R(S); A:S; *S*...
2.1. Dissimilarity from relational database3. Administrating
2.2. Multilevel classification
C1: C2: ...; C1(E11, ...): C2(E21, ...): ...
2.3. Class passing
E / ; E / E1; / E; / E / ; E / / E1
2.4. Class analysis
C():c; E:c | ; E:c \ ; | [C, C:c]; \ C:c
2.5. Class manipulation
C : {C1/}; C: = C1:; C: ~ C1:
2.6. Multitude variable
$mul S; $S = E; = {$S}; {$S} ~; {$S} =; $S*
2.7. Program objects
@po S . (...); @po S . s(...); @po S #n . s(...); $mapState(..., S); $state(...)
2.8. Meaning and other
$(...); $quote(..., S); $unquote(..., S)
2.9. XML data
$readXmlDocument($file "F", C:...), $printXmlDocument($file "F", Q, Q1),
$readXmlKnowledge($file "F", C:...), $printXmlKnowledge($file "F", Q, Q1)
3.1. User account4. Language Reference
$User:"..." ($Password:"...", $Service:"...", $Info:"..."); $login("...", "...", "...")
3.2. Database navigation
$Content:E ($Attribute:E1, ...); E ($HRef:"...")
$base S ~ ; Opens S database as new modifiable.
= $base S ; Opens S database as non-modifiable (only readable).
~ $base S ; Closes S database.
$base S ; Sets S database as current. If database is not opened yet, opens it as modifiable.
Considered auxiliary structure:
$S ;
$S* ; Contractions of specification. If S1 specific name
was declared by $base "S1" before, the $"S"* suggests
S1
database.
Database type is specified by base key word immediately after
$.
The name of the current database may be missing and used only $base.
It needs to be careful with
$S . If a specification is without type,
system tries to remember type or, otherwise, supposes multitude variable
($mul S).
< Tests multibase working > $base "Notes/Test" =; R(A); $base "Notes/RelDB"; =(A); < Non-existent in RelDB > = $"Notes/T"*; < Apparently Notes/Test database > =(A); $base ~; < Clears current database >;
R (A1, ...) - an R relation of an A1, ... attributes.
R:r (A1:a1, ...) - an R namely r relation of an A1 namely a1, ... attributes.
R:(A:a, ...) (A1:a1, ...) - an R namely relation of an A: a, ... , which is relation of A1: a1, .... The attributes of first relation, A:a,..., are key.
The R and A are denotes of relational model: Relation, Attribute. Really for Zigzag, if R(A1, A2) exists, it supposes existence of A1(R) and A2(R).
Considered auxiliary structure:
[E1, ...] - a set of E1, ... objects. For example
[A:a1,
A:a2], or equal A: [a1, a2].
S* . S denotes sequence of non-key symbols and blanks (word sequence). The S* are simple names (element names) in a database beginning with S, for example a* in place of [a1, a2, ... an].
#n . The
# symbol is used for control
of numerical values. The
R: #1 is the same as R: 1, but R:
#1 1 or R: #a causes error message.
note workfellow telephone address 1 Ringer Michael 415 506-0111 4 Broadway Av 503 743-5226 2 Smith Anne 400 297-0752 10 Seventh Av Smith RobertLet us create new empty Notes/RelDB database.
$base "Notes/RelDB" ~;Now input the table information. Description of schema, first statement, is optional!!!. Zigzag's DBMS deduces schema automatically.
note (workfellow, telephone, address); note:#1 ( workfellow:Ringer Michael, telephone:[415 506-0111,503 743-5226], address:4 Broadway Av ); note:#2 ( workfellow:Smith Anne, telephone:400 297-0752, a*:10 Seventh Av );We can use some attributes as key without preliminary declaration. Assume the telephone is key. The following statement will not add new note, because the note: (telephone:400 297-0752) exists, it is note: 2. However it adds new workfellow: Smith Robert attribute to note: 2.
note:( t*:400 297-0752 ) ( w*:Smith Robert, a*:10 Seventh Av );There are more flexible possibilities to enter new data.
workfellow:Smith Robert (note:#2);Moreover, we can describe attributes via request, for example note: #2, in last statement, might be expressed via Smith Anne =note:(:Smith*). Even the note attribute name, itself, we can express via another attribute name = (telephone). So the workfellow:Smith Robert (note:#2) may be expressed via: workfellow:Smith Robert (=(telephone):(:Smith *)). See following section.
= A:a - the A namely a (or the a object of the A class).
Possible variants:Important note: if database includes only one object, A, then =A: equals indefinitude, the =:A equals A, and the =A(): equals A.
= A: - objects of the A class;
= :a - the a object of an arbitrary class;
= R:r (A1:a1, ...) - the R namely r relation of the A1: a1, .... More general form of this request is = E (E1, ...) .
Examples:= [E1=/~/, ...] - the set of the E1 and/no/or the ... . Such important expressions define algebraic operations on the sets. The =[E1=E2] is a intersection, the =[E1~E2] is a difference, the =[E1,E2] is a union.
= R: (A:a) - the R namely relation of the A: a;
= (A:a, B:b) - the relation of the A: a and B: b ;
= ([A:a,B:b]) - the relation of the A: a or B: b ;
= [A,B]: (R:#1) - the A or B namely relation of the R: #1.
Examples:= A:a^b - the A class namely range from a to b.
= [R: ~ (B:)] - the R class no the relation of the B class;
= [:a=A:, B:] - the union of the =[:a = A:] intersection and =[B:]. Evidently = [:a = A:] equals = A: a.
Considered auxiliary structure:
*S . Denotes element names of database ending with
S.
*S* . Element names of database containing
S.
All the complete expressions separated by the ';' are statements. Expression may be description or request. If Zigzag expression begins with '=' or with '~' symbol, its operand (and itself expression) is a request: = Q;, ~ Q;. If expression ends with '=', like D =, the operand, D, is description. If expression ends with '~', system considers operand as request: Q ~. Let us define formally operands in '~' and '=' binary operations: D = Q, Q ~ Q. Look also at these combinations: D = =Q; D = D1=; = [Q, D=];.
See 4.Reference... about all the Zigzag operators,
ordered from highest to lowest precedence. Consecution of operators is
executed from left to the right. For example, A : B : C is equal
to [ A : B ] : C.
note workfellow telephone address 1 Ringer Michael 415 506-0111 4 Broadway Av 503 743-5226 2 Smith Anne 400 297-0752 10 Seventh Av Smith RobertFollowing request reports some objects that belong to the telephone class with values in the range from 415* .
= telephone:415*^;Result in the Report area (in Report window for Sav ZBase Interpreter, or in Report buffer for Sav ZAPI):
telephone:[ 415 506-0111, 503 743-5226 ];We can image relations with address containing 'way' and with one of the 0111 or 0752 phones.
= (address:*way*,*phone:[*0111,*0752]);Result:
note:1;Finally let's output all the notes that have relation with 4... phone or address, but no relation with Anne.
= [note:([*phone,addr*]:4*)~(:*Anne)]; ----- note:1;
We can use: print, printLine, printClass, printRelation, or a abbreviation thereof p, pl, pc, pr. The F is an output file. The Q1, ... are requests.
Considered function structure:
$number(...) - number of ... .
$one(...) - one of ... .
Functions $number(...) and $one(...), or $n(...) and $o(...) respectively, are most often used before printing if database is a big. The result of $n(...) is a sum of data objects. The $o(...) gives only one first object from all pointed in ... parameters.
Useful request statements:
To print object names, we can use =Q statements in place of
$pc(Q).
= . Prints all the database names.
Following are some useful statements printing simple database names
like age word, 30 number, age 30 space combination,
"age:30"
string, or 'age:30' quote.
= S . The S simple name will be printed in any case even
if S is not kept in database.
= {S}. Prints S simple name only if it exists in database
as class name.
= * . Prints all the simple class names.
To understand expressions above, review examples for database that consists of the {A,A:a}.
Statement Result
=; A():a;
=B; B;
={A,B,a} A;
=*; A;
$pl("SCHEMA OF ", *);
$pl("------------------------------------------------------");
$pr(*);
SCHEMA OF address, note, telephone, workfellow ------------------------------------------------------ address ( note ), note ( address, telephone, workfellow ), telephone ( note ), workfellow ( note );Before printing the note: relations there is sense in counting number of its. Then, if number is more than wanted, only one first relation may be printed.
= $number(note:); $pr($one(note:)); ----- 2; note:1( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ], workfellow:Ringer Michael );If you want to print into the Notes/wf415.txt file the workfellows of the notes having the telephone started with 415*, enter:
$p($file "Notes/wf415.txt", workfellow:(note:(telephone:415*)) );Result in the Notes/wf415.txt will be:
workfellow:Ringer MichaelIf you need to print all the complex names in the Notes/c.txt file, enter:
$pc($file "Notes/c.txt");
E ~ (A1:a1, ...) - E is not relation of the A1: a1 and .... The a(~b2) is not correct! The a~(b) is the same as =a~(=b).
R: # - R namely some number. The indefinite number is
last number if the R: # request, and is new number if the R:
# description.
=note:(:Smith*) ~ (:Smith Anne); note:# (:Smith Anne); =note:# = (t*:503 743-5226);Take a look at the result using
$pr( (:Smith*) );
----- note:[ 2 ( address:10 Seventh Av, telephone:400 297-0752, workfellow:Smith Robert ), 3 ( telephone:503 743-5226, workfellow:Smith Anne ) ];
R: [r0 =/~ r1] – R namely r0 is equal/unequal to R namely r1. Expression might be transformed to R: r0 =/~ R: r1. It copies relations from R: r1 to R: r0 or deletes relations of R: r1 from R: r0.
R:r ~ ( ) - R namely r is not relation. Deletes relations.
R:r ~ - R namely r is not. Deletes objects.
$pr(note:); ----- note:[ 1 ( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ], workfellow:Ringer Michael ), 2 ( address:10 Seventh Av, telephone:400 297-0752, workfellow:Smith Robert ), 3 ( telephone:503 743-5226, workfellow:Smith Anne ) ];Set data of Michael Ringer (1 record) to 3 record.
note: [=#3 = =(:Ringer Michael)]; $pr(note:#3); ----- note:3 ( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ], workfellow:[ Ringer Michael, Smith Anne ] );Following fragment demonstrates integrity control. To delete Ringer Michael, we need not point records (1, 3) with this field and we may not use triggers or like SQL CONSTRAINT statements.
:Ringer Michael ~; $pr(note:[#1,#3]); ----- note:[ 1( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ] ), 3( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ], workfellow:Smith Anne ) ];The 1 record does not have workfellow value, so we can clear and it.
note:#1 ~ (); $pr(note:); ----- note:[ 1, 2 ( address:10 Seventh Av, telephone:400 297-0752, workfellow:Smith Robert ), 3 ( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ], workfellow:Smith Anne ) ];
For example, we can import R(A, B) table directly from script:$printTable($file "F", Q, A0, A1, ...) - print table in F file from Q with column names A0 key, A1, .... There is procedure name contraction, $pt(...). The Q is a request. The A0, A1, ... may be requests. If F file parameter is missing, Report area is supposed. The $printTableRows($file "F", Q, A0, A1, ...) procedure, $ptr(...) contraction, prints only table rows, without first line determining column names. If the A0, A1, ... are absent, attributes entered by $readTable(...) will be output in alphabet order.
$rt() <
R ; A ; B
#1; a1; b1
#2; a2; b2
>
Notice large profit of these procedures for database archiving. The F file may be directory, without extension ( .tab). For example: If database consists of R1, R2 tables, $pt($file "Tables") exports all the tables in Tables/R1.tab and Tables/R2.tab accordingly; Then we can import all the files from Tables by $rt($file "Tables").
A first input line of tabular data must define the names of columns.
Only
";" semicolon may be delimiter of the table fields. Values of the field
are separated by the ','. The words with the $ * # " ' [ { ( ] } ) . ^
: / | \ ~ = , ; < > key symbols need be enclosed in the quotes.
The price may be without quotes, $10.2. See distinction of the "..."
and
'...' in the 1.9 section.
$pt($file "Notes/Note.tab", note:, note, address, telephone, workfellow); $base "Notes/ObjDB" ~; $rt($file "Notes/Note.tab", 4, 2, 3); $pt($file "Notes/Workfellow.tab", workfellow: ); $pt(workfellow:); ----- workfellow; telephone; address Smith Anne; 415 506-0111, 503 743-5226; 4 Broadway Av Smith Robert; 400 297-0752; 10 Seventh Av
In this section the S designates '...' or "..." name, or n number.
The n is positive number with possible decimal fraction. The 2147483647.999999 is maximum by default (for non-commercial version). If number has decimal fraction, the digits (at least 0) must be before point. Maximum of digits after point is 6. If element (element's name) does not conform to specified criteria, it is taken to be non-numerical element. Numerical elements may be useful for right order of output data. To select row of numbers, we need use ^ symbol, for example 1^5 denotes [1,2,3,4,5], the 1^ denotes all number >= 1. Note that 1* construction denotes non-numerical elements beginning with 1.
Using A: "...", as A: n, reduces the required database size and accelerates running, but a price must be paid in loss of the system wits for contractions: the =:"...", =:n are not attainable. The R("...") and R(n) also reduce memory. If R:1 ("A":a) exists in database, we cannot confirm that inverse relation, "A":a (R:1), also exists. The =("A") and =(n) contractions are not attainable. Quoting and numbering may be fit for a big database. It may be useful to express repeating class levels: "A": "A" or 1: 1. Single quotes like usual words does not express repeat, the 'A':'A' equals 'A' like A:A equals A. Single quotes may be helpful only to use special symbols as non-special, for instance A: '2*3'.
Considered auxiliary structure:
*S*.... First '*' is optional. The ... ellipsis denotes
nothing, or S, or another S*... construction.
All expressions with '*' are requests to elements existent in database. The '2'*'3' denotes '2...3' quote element in database starting with 2 and ending with 3. The same is for "2"*"3". The #* combination is used to select only all the numbers from current class level.
The '...', "..." simple names and #n number may end up word sequence. For example, a #1, a "b", a b 'c' are allowable, whereas #1 a, "a" "b" and a 'b' c are not correct. So, the * "b" construction is possible and can suggest a "b" or "ab", not "a" "b".
Additional note. System tests existing of correspondent elements in
a database only if it needs to test element connection or presence. For
example,
"a" will be tested in database not only for "a"*,
but also for {"a"} or
"a": expression, and not for ["a",
"b"], or $print("a") statements.
$base "Notes/Test" ~; "office":'0100' (employer:0100, "company":"Unknown"); $pr(); ----- employer( "office" ):100( "office":'0100' ), "company"():"Unknown", "office"( employer, "company" ):'0100'( employer:100, "company":"Unknown" );We can test now interesting expressions.
= "***ELLIPSIS***"; = ""*"ff"*:*'1'*'0'; employer:2147483647.999999; employer:2147483648; = employer:#*; = "company":*"know"*; = ["ATTAINABLE EXPRESSIONS"]; = :'0100'; = "company":"Unknown"; = "office":("company":"Unknown");Derivable result:
"***ELLIPSIS***"; "office":'0100'; employer:[ 100, 2147483647.999999 ]; "company":"Unknown"; "ATTAINABLE EXPRESSIONS"; "office":'0100'; "company":"Unknown"; "office":'0100';Following fragment produces Failure messages.
= {"UNATTAINABLE EXPRESSIONS"}; = :0100; = :"Unknown"; =("company":"Unknown")
Note that R1(A1): R2(A2) expression equals to [R1(A1): R2]
(A2) and equals to R1(A1): [R2(A2)]. The R1: [:R2]
is allowable, but it is the same as R1: R2. It may be useful to
know: the R1: expression assumes all the levels of R1 class,
R1:
R2: ..., but R1:* only one level -
R1: R2.
category: acquainted (property: telephone, property: address ): [ relative (property: propinquity ), workfellow (property: position, property: function ) ];Execute the queries.
= category:relative; $p("-----"); = :acquainted:(property:telephone, property:propinquity); $p("-----"); = category:~:workfellow;Report window will have three equal Zigzag statements separated by the "-----"; string.
category:acquainted:relative;Additional test:
$p("category:*"); $pr(category:*);Result:
category:* category:acquainted( property:[ address, telephone ] );
E / E1 - E1 value of E: class.
/ E - name of class with E value.
/ E / - value of class with E value.
E / / E1 - intermediate levels of class, between E name
and E1 value.
category:[unacquainted:relative = =:relative]; $pr(category:);
category:[ acquainted( property:[ address, telephone ] ):[ relative( property:propinquity ), workfellow( property:[ function, position ] ) ], unacquainted():relative( property:propinquity ) ];It is left to enter many of '/' request combinations and look at result.
$p("= category:unacquainted/"); = category:unacquainted/; $p("= category:*/"); = category:*/; $p("= category/relative"); = category/relative; $p("= category/(property:propinquity, property:address)"); = category/(property:propinquity, property:address); $p("= /relative"); = /relative; $p("= category:acquainted:[/relative]"); = category:acquainted:[/relative]; $p("= [/relative = /workfellow]"); = [/relative = /workfellow]; $p("= /relative/"); = /relative/; $p("= category//relative"); = category//relative;Result:
"= category:unacquainted/"; relative; "= category:*/"; relative, workfellow; "= category/relative"; acquainted:relative, unacquainted:relative; "= category/(property:propinquity, property:address)"; acquainted:relative; "= /relative"; category:[ acquainted, unacquainted ]; "= category:acquainted:[/relative]"; category:acquainted; "= [/relative = /workfellow]"; category:acquainted; "= /relative/"; relative, workfellow; "= category//relative"; acquainted, unacquainted;
E:c | . Result is lower level, c. It is allowed to use ...|..., result of E:[c1,c2] | c1 will be c1.
E:c \ . Result is E. It is allowed to use ...\..., result of [C1,C2]:E \ C1 will be C1.
| C():c . Normalization. Result is C:c.
\ C:c . Result is a [C, C:c] or equal C():c.
category:unacquainted(): ~; = category:;
category:acquainted():[ relative, workfellow ];Now test '|' and '\' combinations.
$p("", "CURRENT (CONSIDERED) OBJECTS", category:); $p("", "CURRENT IDENTIFIERS", category:|); $p("", "CURRENT CATEGORIES", category:\); $p("", "NORMAL OBJECTS", |category:); $p("", "ALL OBJECTS", \category:); $p("", "NORMAL IDENTIFIERS", |category:|); $p("", "NORMAL CATEGORIES", |category:\); $p("", "NORMAL GENERAL CATEGORIES", |category:\*); $p("", "ALL IDENTIFIERS", \category:|); $p("", "ALL CATEGORIES", \category:\);Result:
CURRENT (CONSIDERED) OBJECTS category:acquainted category:acquainted:relative category:acquainted:workfellow CURRENT IDENTIFIERS acquainted relative workfellow CURRENT CATEGORIES category category:acquainted NORMAL OBJECTS category:acquainted:relative category:acquainted:workfellow ALL OBJECTS category category:acquainted category:acquainted:relative category:acquainted:workfellow NORMAL IDENTIFIERS relative workfellow NORMAL CATEGORIES category:acquainted NORMAL GENERAL CATEGORIES category ALL IDENTIFIERS acquainted category relative workfellow ALL CATEGORIES category category:acquainted
C: = C1: - C class is equal to C1 class. Relations of C1: objects are copied to C: with identical values.
C: ~ C1: - C class is unequal to C1 class. Relations of C1: are removed from C: with identical values.
Assume that C: [c, c1], C1(A): [c1(A:a1), c2(A:a2)] are available. Consequently, the C: = C1: entails C(A): [ c, c1(A:a1)].
$pt(workfellow:);
workfellow ; address ; telephone Smith Anne ; 4 Broadway Av; 415 506-0111, 503 743-5226 Smith Robert; 10 Seventh Av; 400 297-0752
Assume we face the need of transmitting workfellow class relation to object:workfellow class relation. Look at the workfellow class values.
= workfellow/;
Smith Anne, Smith Robert;Make value of the object:workfellow class initially.
object:workfellow: {=workfellow/}; $pr(object:);
object:workfellow():[ Smith Anne( ), Smith Robert( ) ];Now we can copy class relations from workfellow:
object:workfellow: = workfellow:; $pr(object:);
object:workfellow():[ Smith Anne ( address:4 Broadway Av, telephone:[ 415 506-0111, 503 743-5226 ] ), Smith Robert ( address:10 Seventh Av, telephone:400 297-0752 ) ];Let's print all the objects with Smith* simple class values.
$p(:Smith*);
object:workfellow:Smith Anne object:workfellow:Smith Robert workfellow:Smith Anne workfellow:Smith RobertLet us print now name of class with Smith* values.
$p(/Smith*);
object:workfellow workfellowThe old workfellow (not object:workfellow) class relation should be deleted.
workfellow(): ~;Lastly we can print information about objects through property/ attributes.
$pt(object:, :workfellow, property/);
object:workfellow; address ; telephone Smith Anne ; 4 Broadway Av; 415 506-0111, 503 743-5226 Smith Robert ; 10 Seventh Av; 400 297-0752
$S = E - $S is equal to E. The S variable assumes E objects. If $S = [] equation, value of $S is null.
= {$S} . Expression extracts the objects equal to the S multitude from a database.
{$S} = . It creates objects of S in a current database.
{$S} ~ . It deletes objects of S from database.
$S* . Using ellipsis for name of multitude variable.
The mul key word is optional and needed only if a multitude variable of other type with the same name was declared earlier. For example, if $base "s1" and $mul s1 were declared, the $s1 implies "Ambiguous" error. Type or name of variable must follow immediately after $.
System supposes that objects of multitude variable are in a current
database and therefore tests objects for the existence only if variable
is in {} brackets, or defines connection. For example, content of
$x
will be tested in ($x), {$x}, $x: , but not in =[$x], $print($x).
Constructions
$x (...) and $x: ... may be used for creation
of new connections in a database. Pay attention that to create or delete
database connection via = or ~ symbol, a variable has to
be bracketed like this [$x] = (...) or [$x] ~ (...).
$mul telephone = tel*:; = $tel*;Result:
telephone:[ 400 297-0752, 415 506-0111, 503 743-5226 ];
=====
$x = $tel*(:Smith Anne); = $x;Result:
telephone:[ 415 506-0111, 503 743-5226 ];
=====
$x = [$x ~ :415*]; = $x;Result:
telephone:503 743-5226;The following fragment illustrates using the variable data in another database.
$p("** Test New Database **"); $base "Notes/Test" ~; = ["Content of $x"]; = [$x]; = ["Current DB"]; = {$x}; {$x} =; = "DB after $x="; = {$x}; {$x} ~; = "DB after $x~"; = {$x};Result:
** Test New Database ** "Content of $x"; telephone:503 743-5226; "Current DB"; ; "DB after {$x}="; telephone:503 743-5226; "DB after {$x}~"; ;
Possible structure:
@po S . s - s field of
@po S program class.
@po S #n . s - s field of @po S #n program
object.
We will not consider but it is possibly to get fields of program class
or object.
Zigzag primarily was dedicated to work under/with Java, so Java objects and classes are most accessible. Look at Java expression, which creates File object.
java.io.File x = new java.io.File("Note");The x is variable pointing Java program object of java.io.File program class. By means of Zigzag we can also create such program object, but expression will be another.
$x = @po java io File.("Note");Name of program class in Zigzag begins with "@po". The varible $x does not have type, we can assign to it anything. Really, in this case, value of $x will be program object's name, like @po java io File #1. Now we can execute method applicable for correspondent Java program object. For example, following Zigzag statement gives to $y variable the absolute path of "Note" file (like C:\SavZBase\demo\Note for Windows).
$y = $x.getAbsolutePath();It is very important to mark some features of working in Zigzag with int, double, boolean and String Java objects. Such objects are expressed directly via real name when play role of Java method's input/output or Java constructor's input parameters. The int is expressed by simple number like 3, the double - by number with point like 34.123, the boolean - by either true or false word, the String - by "..." or word combination like "file1.txt" or first textual file. These real names cannot be subject of Zigzag point-expression. For example, to define length of "file1.txt" string, we need use @po java lang String.("file1.txt").length(), the "file1.txt".length() is not correct.
Considered functions and procedures:
$mapState(..., S). Procedure maps all the attributes of the
... program objects in database. Possible contraction is $ms(...,S).
$state(...). Result of function is a mapping of all the attributes
of the ... program objects. Possible contraction is $s(...).
Let's stop on the $mapState and $state. To realize attributes
of the program objects, they get public fields and invoke the public getX()
methods that are without parameters. System takes the getX() method
as virtual attribute with X name. The last parameter of $mapState
may be quote or string. A $mapState(..., quote) maps
program objects with the attribute values quoted like '...'. For
a $mapState(..., string) attribute values are "...".
$v = @po java util Vector.();
$p($v);
-----
@po java util Vector #1
In the Java, internal name of this object may have view like java.util.Vector@02a. Now we will add to Vector the three String objects with real names red, green, blue and print first Vector's element.
$v.addElement(red);
$v.addElement(green);
$v.addElement(blue);
$v0 = $v.elementAt(0);
$p($v0);
-----
red
Following example we use to demonstrate a using of the $mapState procedure. The objects of the Java class Point instance a Zigzag class point.
point:[ @po java awt Point.(1,2), @po java awt Point.(3,4) ]; $mapState(point:, quote); $pr(point:);
----- point:[ @po java awt Point #1( location:'java.awt.Point[x=1,y=2]', x:1, y:2 ), @po java awt Point #2( location:'java.awt.Point[x=3,y=4]', x:3, y:4 ) ];Assume there is necessity to change the Point object into a state with coordinates x=3, y=4. In this case the $state function may be helpful.
$x = point:(x:3,y:4); $x.move(4,5); = $state($x); {$x} ~ (); {$x} = ($quote($state($x))); $pr(point:);
----- location:java.awt.Point[x=4,y=5], x:4, y:5; point:[ @po java awt Point #1( location:'java.awt.Point[x=1,y=2]', x:1, y:2 ), @po java awt Point #2( location:'java.awt.Point[x=4,y=5]', x:4, y:5 ) ];Persistent program objects are main determinative feature of object databases. Current Vector object may be saved, for example by Vector:$v=, and then get and changed in other Zigzag session. Program classes usually exist separately from database in the program library. Only placing its names in database makes sense. See example of using Array Java class creating object consisting of three String objects.
@po java lang reflect Array =;
$x = @po*Array.newInstance(@po java lang
String, 3);
$p($x);
-----
@po [Ljava lang String; #1
Knowing methods and constructors of correspondent Java objects and classes we can invoke its in Zigzag lightly.
@po*Array.set($x, 0, $v0);
$x0 = @po*Array.get($x, 0);
$p($x0);
$y = @po java lang String.($x0);
$p($y.length());
-----
red
3
Parameter of method or constructor in Zigzag may be multitude. In this case method or constructor is invoked for each element of multitude separately.
string program object: @po java lang String.([a,b,c]);
$z = s*p*o*/;
$p($z);
-----
@po java lang String #6
@po java lang String #7
@po java lang String #8
As you see example before, $z result is multitude of three String objects. We can invoke for this result other methods.
$pl($z.toString());
$pl($z.concat(["1","2","3"]));
-----
a, b, c
a1, a2, a3, b1, b2, b3, c1, c2, c3
Following is example of working with double Java objects. Two methods are used simultaneously.
$pl(@po java lang Math.[floor, ceil](2.33));
-----
2.0, 3.0
Below is example of executing other outside programs via current Java Runtime.
$xrun = @po java lang Runtime.getRuntime();
$p(NOW SEE CALCULATOR);
$xrun.exec("C:\WINNT\System32\calc.exe");
-----
NOW SEE CALCULATOR
By default arguments are requests as here $("A:"). System recognizes description by existence of ";" or for D= construction. For example, the $("A:a;B:b;") creates A:a and B:b database objects. Function helps also to invoke program object's (see section before) methods and fields.
Considered structure:
$quote(..., S) - quote of a ... as S. The S may
be string that denotes "..." values. To produce '...' values, S
may be missing or be quote. Contraction of $quote is $q.
$unquote(..., S) - unquote of a ... that S. The S
may be string or quote (by default) denoting "..." or '...'
source. Contraction of $unquote is $uq.
session:# (date: "@po java util Date.().toString()");
$date = date/(session:#);
$pl("EXPRESSION: ", $date);
$pl("DATE: ", $($date));
-----
EXPRESSION: "@po java util Date.().toString()"
DATE: Sun Mar 30 17:17:44 GMT+04:00 2003
See following example. After R:(A:#, B:#) database will contain relation like R:1(A:1,B:1). Then we create other expression(subject) relation to show how Zigzag request may be saved and get.
R:(A:#, B:#);
expression:request:"A:(R:)" (subject:A);
$xr = :request / (subject:A);
$pl("Meaning of ", $xr);
= $($xr);
-----
Meaning of "A:(R:)"
A:1;
Following is example of the description meaning.
expression:description:"R:(A:#, B:#);" (subject:R);
$xd = :description / (subject:R);
$($xd);
$pl("Meaning of ", $xr, " after second ",
$xd);
= $($xr);
-----
Meaning of "A:(R:)" after second "R:(A:#, B:#);"
A:[
1,
2
];
It is permissible to use several parameters in $(...).
$pl("Meaning of ", $xr, " after third ", $xd);
= $($xd, $xr);
-----
Meaning of "A:(R:)" after third "R:(A:#, B:#);"
A:[
1,
2,
3
];
Parameter of $(...) meaning may be a multitude of the expressions.
expression:request:"B:(R:)" (subject:B);
$xrs = :request/*"("*"R"*")"*;
$p($xrs);
$pl("Meaning of ", $xrs);
= $($xrs);
-----
"A:(R:)"
"B:(R:)"
Meaning of "A:(R:)", "B:(R:)"
A:[
1,
2,
3
],
B:[
1,
2,
3
];
The last fragment demonstrates a using of quote and unquote functions.
$xrs1 = $unquote($xrs, string);
$xrs1 = $quote($xrs1);
expression:new:$xrs1;
= :new:;
= $(:new:''*);
-----
expression:new:[
'A:(R:)',
'B:(R:)'
];
expression:new:[
A:[
1,
2,
3
],
B:[
1,
2,
3
]
];
F is name of either XML file or directory of XML files. Directory is supposed for F name without point. Q request and Q1, C:... roots (paths in database) may be missed in all the procedures. The $file parameter may be missed in printXmlKnowledge and printXmlDocument. If $file is absent, output is a Report area (string buffer for Sav ZAPI).
The XML knowledge differs from XML document in that the knowledge does
not suppose repeatable data (tags or texts) in one class (in one tag).
Internal Zigzag representation of XML data is different for $rd(...)
and $rk(...). For example, test this f.xml file.
<R1>
r1
<r2 A="a"/>
<r2/>
<_1/>
</R1>
Zigzag data for $rd($file "f.xml", C1):
C1:R1:[
1(@T:"r1"),
2(@N:r2,A:"a"),
3(@N:r2),
4(@N:1)
]
For $rk($file "f.xml", C2) Zigzag data will be more general:
C2:R1:[
"r1",
r2(A:"a"),
1
]
<!--
XML is a subset of SGML.
XML enables SGML to be processed on the Web.
-->
<paragraph>
<sentence>
<phrase>
<noun>XML</noun>
<phrase>
<verb>is</verb>
<phrase>
<noun>subset</noun>
<preposition>of</preposition>
<noun>SGML</noun>
</phrase>
</phrase>
</phrase>
</sentence>
<sentence>
<phrase>
<noun>XML</noun>
<phrase>
<verb>enables</verb>
<phrase>
<noun>SGML</noun>
<phrase>
<particle>to</particle>
<verb group="auxiliary">be</verb>
<verb>processed</verb>
<preposition>on</preposition>
<phrase>
<article>the</article>
<noun>Web</noun>
</phrase>
</phrase>
</phrase>
</phrase>
</phrase>
</sentence>
</paragraph>
We can read XML file by rd(...) procedure in document root.
$base "Notes/xml"~;
< XML Data >
$rd($file "Notes/p1.xml", document);
Now we will assign path for is and be text to $x variable. Before declare current database as non-modifiable. Lastly, print $x as XML document.
=$base;
$x = document:(@T:["is","be"],@N:verb);
$pd($x, document);
-----
<paragraph>
<sentence>
<phrase>
<phrase>
<verb>
is
</verb>
</phrase>
</phrase>
</sentence>
<sentence>
<phrase>
<phrase>
<phrase>
<phrase>
<verb>
be
</verb>
</phrase>
</phrase>
</phrase>
</phrase>
</sentence>
</paragraph>
Reflect $x value. It is tree of position numbers of texts and tags in XML. To define $x1 variable as grandparents of $x, we need to ascend two levels up. It will be positions of phrase tags.
$pr($x);
$x1 = $x\\;
$pr($x1);
-----
document:1:[
1:1:2:1:1( @T:"is"
),
2:1:2:2:2:2:1( @T:"be"
)
];
document:1:[
1:1:2( @N:phrase
),
2:1:2:2:2( @N:phrase
)
];
To print in XML format phrases directly belonged to $x1, we can use this.
$pd(=[$x1:*=(@N:phrase)]:, $x1);
-----
<phrase>
<noun>
subset
</noun>
<preposition>
of
</preposition>
<noun>
SGML
</noun>
</phrase>
<phrase>
<article>
the
</article>
<noun>
Web
</noun>
</phrase>
Fragment below selects paths of $x non-having group attribute with value "auxiliary". Then it defines near phrase ancestors and prints its last child.
$x2 = [$x~$x(group:"auxiliary")];
$x3 = |[\$x2=(@N:phrase)];
$pr($x3);
$pd(=$x3:#:, $x3);
-----
document:1:1:1:2( @N:phrase
);
<phrase>
<noun>
subset
</noun>
<preposition>
of
</preposition>
<noun>
SGML
</noun>
</phrase>
By next statement we print all document's descendants from 1 to 3 grandchildren of document in directory "Notes/paragraph". Result will be XML files.
$pd($file "Notes/paragraph", document:, document:*:1^3);
-----
Finally let us to make sense of XML knowledge.
$pk(=$x3:#:, $x3);
$base=;
$rk($file "Notes/p1.xml", combinations);
$pk(combinations:);
-----
<_2>
<_1 _N="noun">
<_1 _T="subset"/>
</_1>
<_2 _N="preposition">
<_1 _T="of"/>
</_2>
<_3 _N="noun">
<_1 _T="SGML"/>
</_3>
</_2>
<combinations>
<paragraph>
<sentence>
<phrase>
<article>
the
</article>
<noun>
SGML
Web
XML
subset
</noun>
<particle>
to
</particle>
<preposition>
of
on
</preposition>
<verb group="auxiliary">
be
enables
is
processed
</verb>
</phrase>
</sentence>
</paragraph>
</combinations>
Considered expression
$User:"..." ($Password:"...", $Service:"...", $Info:"...").
Only administrator has to enter this expression. The $User:"" and
$Service:""
denote arbitrary user and service. If there are some
$User:"...",
then database has limit access.
$login("...", "...", "..."). The $l is a contraction of procedure name. First parameter - a service name, second - a password, third - user name. Parameters may be missed, then its are assumed from previous $login or "".
Current version of Sav Z has 4 system services:
Service | Class |
navigate | Sav.Base.Navigator, Sav.Server.Navigator |
import | Sav.Base.Importer, Sav.Server.Importer |
export | Sav.Base.Exporter, Sav.Server.Exporter |
record | Sav.Server.Recorder |
$base "Notes/Resource"; $User:"Administrator" ($Password:"123456", $Service:""); $User:"Serg" ($Password:"123123", $Service:"navigate"); $User:"" ($Service:"record"); $pr($User:);
-----
$User:[ ""( $Service:"record" ), "Administrator"( $Password:"123456", $Service:"" ), "Serg"( $Password:"123123", $Service:"navigate" ) ];After login with others properties statements will be rejected.
$l("navigate", "123456", "Mole"); $pr();
Considered expression
$Content:E ($Attribute:E1, ...). ZBase's or ZServer's navigator
will have a chance of observing only E: and E1,.... Note
that
$Content:R ($Attribute:A1, ...) is made automatically by $rt()
<R; A1; ...> procedure.
E ($HRef:"..."). ZServer's navigator uses $HRef:"...".
The "..." is a URL reference.
$pr($*:);
-----
$Password:[ "123123"( $User:"Serg" ), "123456"( $User:"Administrator" ) ], $Service:[ ""( $User:"Administrator" ), "navigate"( $User:"Serg" ), "record"( $User:"" ) ], $User:[ ""( $Service:"record" ), "Administrator"( $Password:"123456", $Service:"" ), "Serg"( $Password:"123123", $Service:"navigate" ) ];We need to read table to make automatically $Content class.
$rt() < A ; B ; C ; D ; $HRef a1; b1; c1; d1; "http://www.org.com" a2; b2; c2; d2; >; $pr($Content:);
----- $Content:A( $HRef, B, C, D );Let's change $Content:.
$Content:A ~ ($Attribute:D); $Content:D ($Attribute:A); $pr($Content:); $pt();
-----
$Content:[ A( $HRef, B, C ), D( A ) ]; A; $HRef; B; C a1; "http://www.org.com"; b1; c1 a2; ; b2; c2 D; A d1; a1 d2; a2It remains only to see as navigator is working.
E Expression Q Request in =Q | ~Q | Q~ | Q~Q | D=Q | $print(Q,...) D Description in D; | D= | D=Q R|R:r Relation name in R(E) | R:r(E) relation A|A:a Relation attribute in E(A,...) | E(A:a,...) relation C:c Data object in C:[c:[...],...] class C Class name in C:E c Class value (or Instance name) in E:c A|B|C|...|R|... Element (or Simple object) a|b|c|...|r|... Element (or Simple object) S|s Sequence of characters, which has contextual limitation N|n Number
Syntax designations:
Z Key symbol $ | * | # | " | ' | | [ | { | ( | ] | } | ) | . | ^ | : | / | | | \ | ~ | = | , | ; | < | > C Non-key character L Letter D Digit I Integer D... N Number I | I.I W Word C... ND Number Designation N | #N | # | #* SC String Combination "..." | "..."* | "..."*SC QC Quote Combination '...' | '...'* | '...'*QC WW Word sequence W | W WW WC Word Combination WW | WW* | WW*WC NC Name Combination ND | SC | QC | WC | WC NC Nm Element name * | * NC | NC (Simple name) SNm Specific name WW | "..." | WW* | "..."* Sp Specification $W SNm | $SNm Exp Expression Nm | Sp | Exp Z | Z Exp Stm Statement Exp, ... Scr Script Stm; ...Expressions ordered by priority:
1 Sp | Sp(Exp, ...) $base SNm 1.2 $file SNm 1.5, 1.8 $mul SNm 2.6 $Sp(Exp,...) 1.5, 1.8, 2.7, 2.9, 3.1 $W 3.1, 3.2 1 Nm SC | QC 1.9 ND 1.6, 1.9 ...*... 1.3, 1.4, 1.9 * 1.5, 2.2 1 <...> 1.2, 1.8 1 {Exp, ...} 2.5, 2.6 1 [Exp, ...] 1.3, 1.4 1 (Exp, ...) 1.4 2 Exp(Exp, ...) 1.3, 1.4 3 Exp.Exp 2.8 4 ^Exp | Exp^Exp | Exp^ 1.4 5 Exp:Exp 1.3, 1.9, 2.2 5 :Exp | Exp: 1.4 6 /Exp | Exp/ 2.3 6 Exp/Exp | Exp//Exp 2.3 7 |Exp | \Exp 2.4 7 Exp|Exp | Exp\Exp 2.4 7 Exp| | Exp\ 2.4 8 ~Exp 1.2 8 =Exp 1.4, 1.6 9 Exp~Exp 1.4, 1.6, 1.7, 2.5, 2.6 10 Exp=Exp 1.4, 1.6, 1.7, 2.5, 2.6 11 Exp~ | Exp= 1.2, 1.7 12 Exp,Exp 1.3, 1.4 13 Stm;Stm 1.3Procedures
$p | $print 1.5 $pl | $printLine 1.5 $pc | $printClass 1.5 $pr | $printRelation 1.5 $pt | $printTable 1.8 $ptr | $printTableRows 1.8 $rt | $readTable 1.8 $ms | $mapState 2.7 $rd | $readXmlDocument 2.9 $pd | $printXmlDocument 2.9 $rk | $readXmlKnowledge 2.9 $pk | $printXmlKnowledge 2.9 $l | $login 3.1Functions
$n | $number 1.5 $o | $one 1.5 $s | $state 2.7 $ | $meaning 2.8 $q | $quote 2.8 $uq | $unquote 2.8