Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 2364

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>5.11 Selecting Files</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="node29.html#section.widgets-2.wm">&lt;&lt; Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node31.html#section.widgets-2.help">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.widgets-2.file"><H2><A name="section.widgets-2.file">5.11 Selecting Files</A></H2><P> Tk provides for predefined dialogs to select files for being opened or for being saved. </P><P> Selecting a file to be opened can be done with the command <CODE>tk_getOpenFile</CODE>. For example, an arbitrary file can be selected as shown in <A href="node30.html#figure.widgets-2.file">Figure&nbsp;5.11</A>. If the command returns the empty string (that is <CODE>nil</CODE>), the selection dialog has been canceled. Otherwise, the string&nbsp;<CODE>S</CODE> gives the filename of the file to be opened. </P><DIV id="figure.widgets-2.file"><HR><P><A name="figure.widgets-2.file"></A></P><P> </P><DIV align="center"><IMG alt="" src="file.gif"></DIV><P> <A name="label260"></A> </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">case</SPAN>&nbsp;{Tk<SPAN class="keyword">.</SPAN>return&nbsp;tk_getOpenFile}<BR><SPAN class="keyword">of</SPAN>&nbsp;nil&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<SPAN class="keyword">skip</SPAN>&nbsp;<BR><SPAN class="keyword">elseof</SPAN>&nbsp;S&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;{Browse&nbsp;file({String<SPAN class="keyword">.</SPAN>toAtom&nbsp;S})}<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P> </P><P class="caption"><STRONG>Figure&nbsp;5.11:</STRONG> Selecting files.</P><HR></DIV><P> </P><P> The visual appearance of the file selector depends on the operating system Oz runs on. For example, the file selector for Unix based operating systems is shown in <A href="node30.html#figure.widgets-2.file">Figure&nbsp;5.11</A>. Running Oz under Windows uses the Windows specific file selector dialog. </P><P> To select filenames for saving the command <CODE>tk_getSaveFile</CODE> can be used in the same way as above. The difference is that this command does not require that a file with the selected filename already exists. </P><P> Reference information on both commands can be found in <A href="../tcltk/TkCmd/tk_getOpenFile.htm"><KBD>tk_getOpenFile</KBD></A>. </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node29.html#section.widgets-2.wm">&lt;&lt; Prev</A></TD><TD><A href="node19.html">- Up -</A></TD><TD><A href="node31.html#section.widgets-2.help">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>