Okay, after struggling for hours with eval, I came up with this which seems to do the trick...apparently eval is not even necessary:
[codebox]// Global Procedure: f_arrayVector
// - create an array of vectors from XYZ ASCII data
//
// USAGE: f_arrayVector($fname);
//
//-----Example:-----
// source f_arrayVector;
// $data = f_arrayVector("/Users/loquat149/Documents/maya/projects/Dave/data/xyz.dat");
//-----Notes:-----
// On the Mac, data files need to be saved with linefeeds (LF) so the FGETLINE
// command can parse lines.
// -----Author:-----
// by loquat149, May-2008
global proc vector[] f_arrayVector(string $fname) {
// Declare variables:
vector $data[];
// Open file for reading:
int $fileId = `fopen $fname "r"`;
// Loop until reaching the end of the file:
int $n = 0;
while( !feof($fileId) ) {
// Get one line at at time:
string $line = `fgetline $fileId`;
// Parse columns (space-delimited):
string $xyz[] = stringToStringArray($line, " ");
// Check the input on 1st iteration:
if ($n==0) {
if (size($xyz)!=3) {
error "Input file doesn't have 3 columns!";
}
}
// Build command string:
string $cmd= ("<<" + $xyz[0] + "," + $xyz[1] + "," + $xyz[2] + ">>;" );
// Add vector to array:
$data[$n] = ($cmd);
$n++; // increment counter
}
// Close the file:
fclose $fileId;
// Return array of vectors:
return $data;
};
[/codebox]
Suggestions for improvements are welcome,
Dave