Appendix A 507
Additional Lab Exercises
Working with Files
Key Points
n Generating an Array: Use
randomize(ramp(100,0,1), 0, 1) in
the
Formula object to create an array of 100 random numbers. The
ramp() function generates an ordered array and delivers it to the
randomize() function, which then generates random values between 0
and 1.
n Time Stamp: The
now() function is used in the expression field of the
I/O Transaction dialog box for transaction one in the To File
object. When you change the format to TIME STAMP FORMAT, the dialog
box displays additional buttons to specify how the time will be stored.
n Storing Two Values in a Line: In both the third and fourth transactions
in the
To File object, a constant Text string is stored, followed by a
Real value. For example, in the third transaction you type "Mean: ",B
in the expression field of the
I/O Transaction box (assuming the
mean value will be on the
B input pin).
n Extracting a Value From a File: To get to the mean and standard
deviation, first send an
EXECUTE REWIND to position the read pointer at
the beginning. Then use
NULL with the proper format to READ past the
time stamp and real array. (This will throw away the values read instead
of putting them in an output terminal.) Finally, read the last two lines in
the file as strings.
n Junction: Use the
Flow ⇒ Junction object to connect more than one
output to a single input, such as connecting the
mean and sdev outputs
to the
Logging AlphaNumeric display.