ReJump


Chapter 6:: Manual:: ReJump DataFile
Technology



 


Home

Datafile
About
News
Manual
<...
Chapter 6
...>
Download
Contacts








Links

Now more complex example. We need to create favourite web-adresses storage. Every web-address has two characteristics: "name" and "address".

Data input script looks as follows:
add_webaddr=add(data-web,addr);
update(add_webaddr,Text,$i.webaddr);
add_sitename=add(add_webaddr,sitename);
update(add_sitename,Text,$i.sitename);

Note, that you should fill fields "sitename" and "webaddr" in the input form.

We know how to get an access to the object with extension "addr" which contains site address (URL):
<&data-web:addr>
That expression returns list of objects with sites' names. You can put them into templates.

If you have an object with known URL and you want to get an object with the same name see the following expression. You need to process it. Assume "$1" is object "addr" which was transmitted to the template. Expression <&$1:sitename> returns an identifier of object which contains site name.

Example:
Template "web_tpl" contains:
<@data-web:addr<site_tpl/#1@>

Template "site_tpl" contains:
<&$1:name?Value> (<&$1?Value>)

Assume there are files
web/0.addr contains URL http://www.rejump.com
web/0--addr/0.sitename contains ReJump
web/1.addr contains http://www.microsoft.com
web/1--addr/0.sitename contains Microsoft

The result of processing template "web_tpl" is:
ReJump (http://www.rejump.com)
Microsoft (http://www.microsoft.com)

If we want to get objects with sites' names - objects with extension ".sitename".
You can do it like this:
<&data-web:addr:sitename>

Note, that operator ":" allows to use it not only with objects, but with lists. "data-web:addr" is the list of objects.

Example:
Template web2_tpl
(<@data-web:addr:sitename<addr2_tpl/#1@>)

Template addr2_tpl
<&$1?Value>;

The result is:
(ReJump; Microsoft;)

Relation between address and its name ":sitename" is link.

Physical link looks in the following way. You create folder for an object and put files with information about links there. For example, create folder "0--addr" for object "0.addr" and put there file "0.sitename". All input infirmation will store there.
It is represented in the previous example.
("." substitutes instead of "--" when the folder with links is being created)

See more complex example. Add to web-address one more characteristic - theme, and try to arrange links on themes.

Themes.
Assume files which designate themes are in the folder "web". They have extension ".th". To get an access to them use expression <&data-web:th>.

Assume we have two themes.
Physically they are files "web/0.th" and "web/1.th", logically - objects "data-web-0--th" and "data-web-1--th". File "0.th" has contents "Soft", file "1.th" has contents "Web Soft".

Input field like "select" on the form you can form in the following way:

Template "theme_select":
<select name=theme>
<@data-web:th<theme_s/#1@>
</select>

Template "theme_item":
<option value="$1"><&$1?Value></option>

The result of template "theme_select" processing:
<select name="theme">
<option value="data-web-0--th">Soft</option>
<option value="data-web-1--th">Web Soft</option>
</select>

In template "theme_item":
$1 - name of object-theme
<&$1?Value> - name of theme

This field "select" need to be put in the script of link adding (see high on the section).

Add operator to the script:
addLink(add_webaddr,in,$i.theme);
It creates link to catenate web-address with theme.
Assume "add_webaddr" equals "data-web-1--addr". During operator
"addLink(data-web-1--addr,in,data-web-0--th)" execution; file "0.in" with contents "@data-web-0--th" would be added to the folder "/web/1--addr".

Expression <&data-web-1--addr:in> gives us "data-web-0--th".

Backward links:
There is one more operator besides operator ":", which was used in the previous example. It's operator ".".
That operator allows to get a list of objects refers to given.

Example:
Expression <&data-web-0--th.in> will return "data-web-1--addr" if only one object (above-cited)refers on the theme. Or {data-web-0--addr,data-web-1--addr} if objects "data-web-0--addr" and "data-web-1--addr" refer on the theme.

That feature's name is "backward links". They also have representation in files in folder "/web/0.th". In the previous example they are files with extension "._in" with contents "@data-web-0--addr" and "@data-web-1--addr"correspondingly.

Here "." is similar to ":", but acts for backward links.
Write ":in" and get the theme from link. Write ".in" and get all links on the theme from it.
Backward links are created automatically during direct link creation.

Index
Download
Contacts
If you have any questions, please, contact us via email: datafile@rejump.com.


© 2002-2009 Алексей Мась, ReJump