/usr/share/doc/swi-prolog-doc/UserGuide/sec-A.2.html is in swi-prolog-doc 5.6.59-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Programming in XPCE/Prolog: Section A.2</TITLE><LINK REL=home HREF="index.html">
<LINK REL=contents HREF="Contents.html">
<LINK REL=index HREF="DocIndex.html">
<LINK REL=summary HREF="summary.html">
<LINK REL=previous HREF="sec-A.1.html">
<LINK REL=next HREF="sec-A.3.html">
<STYLE type="text/css">
/* Style sheet for SWI-Prolog latex2html
*/
dd.defbody
{ margin-bottom: 1em;
}
dt.pubdef
{ background-color: #c5e1ff;
}
pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}
div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}
div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}
div.author
{ text-align: center;
font-style: italic;
}
div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}
div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}
div.toc-h1
{ font-size: 200%;
font-weight: bold;
}
div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}
div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}
div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}
span.sec-nr
{
}
span.sec-title
{
}
span.pred-ext
{ font-weight: bold;
}
/* Footnotes */
sup.fn { color: blue; text-decoration: underline; }
span.fn-text: { display: none; }
sup.fn span {display: none;}
sup:hover span
{ display: block !important;
position: absolute; top: auto; left: auto; width: 80%;
color: #000; background: white;
border: 2px solid;
padding: 5px; margin: 10px; z-index: 100;
font-size: smaller;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="white">
<DIV class="navigate"><A class="nav" href="index.html"><IMG SRC="home.gif" BORDER=0 ALT="Home"></A>
<A class="nav" href="Contents.html"><IMG SRC="index.gif" BORDER=0 ALT="Contents"></A>
<A class="nav" href="DocIndex.html"><IMG SRC="yellow_pages.gif" BORDER=0 ALT="Index"></A>
<A class="nav" href="summary.html"><IMG SRC="info.gif" BORDER=0 ALT="Summary"></A>
<A class="nav" href="sec-A.1.html"><IMG SRC="prev.gif" BORDER=0 ALT="Previous"></A>
<A class="nav" href="sec-A.3.html"><IMG SRC="next.gif" BORDER=0 ALT="Next"></A>
</DIV>
<H2><A NAME="sec:A.2"><SPAN class="sec-nr">A.2</SPAN> <SPAN class="sec-title">Miscellaneous
topics</SPAN></A></H2>
<P>This section discusses various topics that were omitted from the
Guided Tour to keep it simple.
<H3><A NAME="sec:A.2.1"><SPAN class="sec-nr">A.2.1</SPAN> <SPAN class="sec-title">Specifying
callback to prolog</SPAN></A></H3>
<P>Using the background popup of the behaviour editor, the object <A NAME="idx:prolog:615"></A><B>@prolog</B>
(see <A class="sec" href="pceprolog.html">section 6</A>) can be added to
the model. Select <B>Add Send Port</B> to add a new predicate to the <A NAME="idx:prolog:616"></A><B>@prolog</B>
interface. Then type the name of the predicate. Now link the event-port
of a control to the predicate and link the arguments.
<P>If the predicate is not defined, select `Edit' on menu of <A NAME="idx:prolog:617"></A><B>@prolog</B>
to start PceEmacs on the source file. Now drag the predicate to the
PceEmacs window. This will insert the head of the predicate at the
caret. See <A class="fig" href="sec-A.2.html#fig:diaprolog">figure 38</A>
<P><A NAME="fig:diaprolog"></A>
<CENTER>
<IMG SRC="diaprolog.gif">
</CENTER>
<TABLE ALIGN=center WIDTH="75%"><TR><TD>
<B>Figure 38 : </B>Specifying Call-back to Prolog</TABLE>
<H3><A NAME="sec:A.2.2"><SPAN class="sec-nr">A.2.2</SPAN> <SPAN class="sec-title">Advanced
example of behaviour</SPAN></A></H3>
<P><A class="fig" href="sec-A.2.html#fig:viewer">Figure 39</A> is the
screen dump of an application and its behaviour model of a tool that
shows all files in a directory and clicking on a file shows the file's
contents in the editor to the left. It demonstrates various aspects of
advanced features for specifying behaviour.
<P>
<UL>
<LI><I>The text-field <B>directory</B></I><BR>
Represented in the model by (1). It is a normal <A class="" href="summary.html#class:text_item">text_item</A>,
but the <A NAME="idx:textitembothtype:618"></A>`<B>text_item<CODE><-></CODE>type</B>'
field is set to `directory'. This implies the
<B><CODE><-</CODE>selection</B> of the text-item will return a <A class="" href="summary.html#class:directory">directory</A>
object.
<LI><I>Showing the files of the directory</I><BR>
If the text-item is modified, a list of files in the directory should be
shown in the `file_list', a <A class="" href="summary.html#class:list_browser">list_browser</A>.
The method
<A NAME="idx:listbrowsersendmembers:619"></A>`<B>list_browser<CODE>-></CODE>members</B>'
may be used to fill the browser with a collection of items. This method
expects a <A class="" href="summary.html#class:chain">chain</A> object.
The get method <A NAME="idx:directorygetfiles:620"></A>`<B>directory<CODE><-</CODE>files</B>'
provides a chain holding the names of all files in the directory.
<P>Thus, the event-port `message' of the directory field must invoke the
send-port `members' of the file-list. The argument should be the result
of applying <B><CODE><-</CODE>files</B> on the <B><CODE><-</CODE>selection</B>
of the text-entry field. To specify this, the get-port `selection' is <EM>expanded</EM>
using the popup menu of this port. This operation adds (2) to the
diagram. The system infers this expansion is an instance of class <A class="" href="summary.html#class:directory">directory</A>
and shows the most useful get-ports in its get-port menu. The `files'
get-port is added to (2) and linked to the activation relation between
<A NAME="idx:textitemsendmessage:621"></A>`<B>text_item<CODE>-></CODE>message</B>'
and <A NAME="idx:listbrowsersendmembers:622"></A>`<B>list_browser<CODE>-></CODE>members</B>'.
<P>To <B>test</B> this part, put the Dialog editor in `run' mode, type
the name of a directory and <B>ENTER</B> to activate the event-port. If
anything goes wrong, the <B>Simulate</B> option of the various popup
menus in the diagram may be used to test small parts of the model. The <EM>Documentation</EM>
option of these menus may be used to view the relevant documentation
from the online manual tools.
<LI><I>Specifying the initial directory as a parameter</I><BR>
Initialisation of the dialog is expressed by adding one or more <EM>init-ports</EM>
to the diagram using the background menu. In this particular case, we
would like to be able to pass a directory to start as a parameter.
Hence, a <EM>parameter-port</EM> is added with the name `dir'. First,
the <B><CODE>-></CODE>selection</B> is set using the parameter and
then the item is
<B><CODE>-></CODE>executed</B> to activate its <B><CODE>-></CODE>message</B>.
<P>Code generation will append the directory parameter to the identifier
of the <A NAME="idx:dialog2:623"></A><A class="pred" href="sec-A.1.html#dialog/2">dialog/2</A>
clause. In this case, this clause will start as:
<PRE class="code">
dialog(viewer(Dir),
[ ...
]).
</PRE>
<P>An instance is opened using the following calls:
<PRE class="code">
...,
make_dialog(D, viewer(StartDir)),
send(D, open),
...
</PRE>
<P>
<LI><I>Showing a file</I><BR>
The first step is to link the event-port `select_message' of the
file_list to the file_contents (3) <A class="" href="summary.html#class:editor">editor</A>
object's send-port `load'. This method expects a file. Due to the type
conversion rules of class <A class="" href="summary.html#class:file">file</A>,
the name of a file suffices, but the names from file_list are relative
to the directory object (2). First, the
<B><CODE><-</CODE>selection</B> of the file_list is expanded,
resulting in (5), a
<A class="" href="summary.html#class:dict_item">dict_item</A> object.
The <A NAME="idx:dictitemgetkey:624"></A>`<B>dict_item<CODE><-</CODE>key</B>'
contains the name of the file.
<P>The method <A NAME="idx:directorygetfile:625"></A>`<B>directory<CODE><-</CODE>file</B>'
can be used to create a <A class="" href="summary.html#class:file">file</A>
object from a name, that specifies an absolute path. A get-port `file'
is added to (2) and this get-port is linked to the activation relation.
This get operation requires the filename argument from (5).
</UL>
<P><A NAME="fig:viewer"></A>
<CENTER>
<IMG SRC="viewer.gif">
</CENTER>
<TABLE ALIGN=center WIDTH="75%"><TR><TD>
<B>Figure 39 : </B>A file viewer</TABLE>
<H3><A NAME="sec:A.2.3"><SPAN class="sec-nr">A.2.3</SPAN> <SPAN class="sec-title">Specifying
conditional actions</SPAN></A></H3>
<P><A class="fig" href="sec-A.2.html#fig:diacond">Figure 40</A> shows an
example of a conditional activation relation. A conditional relation is
created making a connection from the fat dot in the middle of an
activation relation to a send-port. Success or failure of the send-port
will be interpreted as a condition on the activation relation.
<P><A NAME="fig:diacond"></A>
<CENTER>
<IMG SRC="diacond.gif">
</CENTER>
<TABLE ALIGN=center WIDTH="75%"><TR><TD>
<B>Figure 40 : </B>Conditional activation</TABLE>
<H3><A NAME="sec:A.2.4"><SPAN class="sec-nr">A.2.4</SPAN> <SPAN class="sec-title">Load
and save formats</SPAN></A></H3>
<P>The Dialog Editor provides two load/save formats. The <B>Load</B>,
<B>Save</B>, <B>Save As</B> and <B>Save All</B> save and load the status
of the dialog editor as an <font size=-1>XPCE</font> object using <A NAME="idx:objectsendsaveinfile:626"></A>`<B>object<CODE>-></CODE>save_in_file</B>'.
This format loads quickly, but is rather vulnerable to future changes in
the Dialog Editor or any of the graphical classes.
<P>Alternatively, the Dialog Editor can restore itself from the
identifier of a <A NAME="idx:dialog2:627"></A><A class="pred" href="sec-A.1.html#dialog/2">dialog/2</A>
clause generated by itself or (slightly) modified. In this case, the
layout of the behaviour model will be lost.
<P>We advice to use Save/Load during application development. If, during
the maintenance phase of your product it is necessary to modify a
dialog, either simply edit the <A NAME="idx:dialog2:628"></A><A class="pred" href="sec-A.1.html#dialog/2">dialog/2</A>
clause, or load both the application and the dialog editor and use <B>Reload
From Id</B> to restart the Dialog Editor.
<P></BODY></HTML>
|