<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Does ChucK a method of writing and reading ints, 
floats or strings from a file? The documentation</FONT></DIV>
<DIV><FONT face=Arial size=2>only includes WvIn and WvOut for file 
I/O.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I hacked a technique for sending data by scaling it 
to values -1.0 to&nbsp;1.0 and sending it to a sound file:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>//WRITE1.ck//</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>// write values to file</FONT></DIV>
<DIV><FONT face=Arial size=2>Step x =&gt; WvOut file =&gt; blackhole;<BR>"data" 
=&gt; file.sndFilename;<BR>float n;<BR>for (int ii; ii&lt;20; 
ii++)<BR>{<BR>&nbsp;ii/20.0 =&gt; n;<BR>&nbsp;&lt;&lt;&lt; n 
&gt;&gt;&gt;;<BR>&nbsp;n =&gt; x.next;<BR>&nbsp;1::samp =&gt; 
now;<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2>file.closeFile();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>These values can then be read sequentially with 
WvIn:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>//READ1.ck//</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>WvIn w =&gt; blackhole;<BR>"data.snd" =&gt; 
w.path;<BR>float n;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>repeat(20)<BR>{<BR>&nbsp;1::samp =&gt; 
now;<BR>&nbsp;w.last() =&gt; n;<BR>&nbsp;&lt;&lt;&lt; n 
&gt;&gt;&gt;;<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>But I don't get exactly the same values returned; 
ie, I try to store the value 0.500000 but when </FONT><FONT face=Arial 
size=2>read,</FONT></DIV>
<DIV><FONT face=Arial size=2>I get </FONT><FONT face=Arial size=2>0.500015. 
That's a significant variance.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Does anyone know where this variance comes from, or 
how to get around it? And is this the only way</FONT></DIV>
<DIV><FONT face=Arial size=2>to store and read data? What about strings from 
files?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Joel</FONT></DIV></BODY></HTML>