/usr/share/mozart/doc/apptut/node24.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>A Data and Code Fragments</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node23.html">- Up -</A></TD></TR></TABLE><DIV id="chapter.code"><H1><A name="chapter.code">A Data and Code Fragments</A></H1><P> This appendix contains code fragments left out in the text's chapters. </P><DIV id="section.code.development"><H2><A name="section.code.development">A.1 Application Development</A></H2><P></P><DL><DT><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A name="label72">Body for DB.oz</A><SPAN class="chunkborder">>=</SPAN></SPAN></DT><DD class="code"><CODE><SPAN class="keyword">define</SPAN> <BR> Data = {Dictionary<SPAN class="keyword">.</SPAN>new}<BR> Ctr = {New <SPAN class="keyword">class</SPAN> <SPAN class="type">$</SPAN> <BR> <SPAN class="keyword">prop</SPAN> locking<BR> <SPAN class="keyword">attr</SPAN> i:0<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN>(I <SPAN class="keyword"><=</SPAN> 0)<BR> <SPAN class="keyword">lock</SPAN> i <SPAN class="keyword">:=</SPAN> I <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">get</SPAN>($)<BR> <SPAN class="keyword">lock</SPAN> <SPAN class="keyword">@</SPAN>i <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">inc</SPAN>($)<BR> <SPAN class="keyword">lock</SPAN> I=<SPAN class="keyword">@</SPAN>i<SPAN class="keyword">+</SPAN>1 <SPAN class="keyword">in</SPAN> i <SPAN class="keyword">:=</SPAN> I I <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> init()}<BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Add</SPAN> X}<BR> I={Ctr inc($)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Dictionary<SPAN class="keyword">.</SPAN>put Data I X}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Get</SPAN> ID}<BR> {Dictionary<SPAN class="keyword">.</SPAN>get Data ID}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">GetAll</SPAN>}<BR> {Map {Dictionary<SPAN class="keyword">.</SPAN>keys Data}<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> K}<BR> {AdjoinAt {Dictionary<SPAN class="keyword">.</SPAN>get Data K} key K}<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN> <BR> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Remove</SPAN> ID}<BR> {Dictionary<SPAN class="keyword">.</SPAN>remove Data ID}<BR> <SPAN class="keyword">end</SPAN></CODE></DD></DL><P> </P><DL><DT><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A name="label73">Implementation of Book</A><SPAN class="chunkborder">>=</SPAN></SPAN></DT><DD class="code"><CODE>T ={New Tk<SPAN class="keyword">.</SPAN>toplevel tkInit}<BR>F1={New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent:T relief:sunken bd:2)}<BR>V ={New Tk<SPAN class="keyword">.</SPAN>variable tkInit(Fs<SPAN class="keyword">.</SPAN>1<SPAN class="keyword">.</SPAN>key)}<BR>{Tk<SPAN class="keyword">.</SPAN>batch <BR> grid(b({Map [<SPAN class="string">''</SPAN> <SPAN class="string">'From'</SPAN> <SPAN class="string">'To'</SPAN> <SPAN class="string">'Price'</SPAN>]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A}<BR> {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent:F1 text:A<BR> relief:raised bd:1)}<BR> <SPAN class="keyword">end</SPAN>})<BR> padx:1 pady:1 sticky:ew) <SPAN class="keyword">|</SPAN> <BR> {Map Fs<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> F}<BR> grid({New Tk<SPAN class="keyword">.</SPAN>radiobutton tkInit(parent:F1 var:V<BR> value:F<SPAN class="keyword">.</SPAN>key)}<BR> b({Map [<SPAN class="string">'from'</SPAN> to price]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> A}<BR> {New Tk<SPAN class="keyword">.</SPAN>label tkInit(parent:F1 text:F<SPAN class="keyword">.</SPAN>A)}<BR> <SPAN class="keyword">end</SPAN>}))<BR> <SPAN class="keyword">end</SPAN>}}<BR>F2={New Tk<SPAN class="keyword">.</SPAN>frame tkInit(parent:T)}<BR>[FN LN EM] =<BR>{Map [<SPAN class="string">'First name'</SPAN> <SPAN class="string">'Last name'</SPAN> <SPAN class="string">'E-Mail'</SPAN>]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> S}<BR> E={New Tk<SPAN class="keyword">.</SPAN>entry tkInit(parent:F2 width:20 bg:wheat)}<BR> <SPAN class="keyword">in</SPAN> <BR> {Tk<SPAN class="keyword">.</SPAN>send grid({New Tk<SPAN class="keyword">.</SPAN>label<BR> tkInit(parent:F2 text:S<SPAN class="keyword">#</SPAN><SPAN class="string">':'</SPAN> anchor:w)}<BR> E<BR> sticky:ew)}<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> {E tkReturnAtom(get $)}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN>}<BR>B={New Tk<SPAN class="keyword">.</SPAN>button<BR> tkInit(parent:T text:<SPAN class="string">'Okay'</SPAN> <BR> action: <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN>}<BR> Get=form(first: {FN}<BR> last: {LN}<BR> email: {EM}<BR> key: {V tkReturnInt($)})<BR> {T tkClose}<BR> <SPAN class="keyword">end</SPAN>)}<BR><SPAN class="keyword">in</SPAN> <BR>{Tk<SPAN class="keyword">.</SPAN>send pack(F1 F2 B padx:1<SPAN class="keyword">#</SPAN>m pady:2<SPAN class="keyword">#</SPAN>m)}</CODE></DD></DL><P> </P><DL><DT><SPAN class="chunktitle"><SPAN class="chunkborder"><</SPAN><A name="label74">Sample flights</A><SPAN class="chunkborder">>=</SPAN></SPAN></DT><DD class="code"><CODE>[f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Paris'</SPAN> to:<SPAN class="string">'Stockholm'</SPAN> price:234)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Saarbrücken'</SPAN> to:<SPAN class="string">'Paris'</SPAN> price:345)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'New York'</SPAN> to:<SPAN class="string">'Saarbrücken'</SPAN> price:567)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'New York'</SPAN> to:<SPAN class="string">'Bruxelles'</SPAN> price:363)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Paris'</SPAN> to:<SPAN class="string">'Saarbrücken'</SPAN> price:834)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Stockholm'</SPAN> to:<SPAN class="string">'Bruxelles'</SPAN> price:333)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'London'</SPAN> to:<SPAN class="string">'Saarbrücken'</SPAN> price:523)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Saarbrücken'</SPAN> to:<SPAN class="string">'London'</SPAN> price:457)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Bruxelles'</SPAN> to:<SPAN class="string">'New York'</SPAN> price:324)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Boston'</SPAN> to:<SPAN class="string">'Stockholm'</SPAN> price:765)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Stockholm'</SPAN> to:<SPAN class="string">'New York'</SPAN> price:344)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Sydney'</SPAN> to:<SPAN class="string">'Saarbrücken'</SPAN> price:3452)<BR> f(<SPAN class="string">'from'</SPAN>:<SPAN class="string">'Sydney'</SPAN> to:<SPAN class="string">'Stockholm'</SPAN> price:2568)]</CODE></DD></DL><P> </P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node23.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A> and <A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|