<!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> </DIV>
<DIV><FONT face=Arial size=2>I hacked a technique for sending data by scaling it
to values -1.0 to 1.0 and sending it to a sound file:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>//WRITE1.ck//</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>// write values to file</FONT></DIV>
<DIV><FONT face=Arial size=2>Step x => WvOut file => blackhole;<BR>"data"
=> file.sndFilename;<BR>float n;<BR>for (int ii; ii<20;
ii++)<BR>{<BR> ii/20.0 => n;<BR> <<< n
>>>;<BR> n => x.next;<BR> 1::samp =>
now;<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2>file.closeFile();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> </DIV>
<DIV><FONT face=Arial size=2>//READ1.ck//</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>WvIn w => blackhole;<BR>"data.snd" =>
w.path;<BR>float n;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>repeat(20)<BR>{<BR> 1::samp =>
now;<BR> w.last() => n;<BR> <<< n
>>>;<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> </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> </DIV>
<DIV><FONT face=Arial size=2>Joel</FONT></DIV></BODY></HTML>