[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Is this a Bug in InFile getDouble (& other InFile get* methods)?
From: |
Rick Riolo |
Subject: |
Is this a Bug in InFile getDouble (& other InFile get* methods)? |
Date: |
Sun, 7 Feb 1999 08:41:40 -0500 (EST) |
Here is a little program I wrote to test
getDouble and friends (I've tried it with a getInt, too):
#import <simtools.h>
int main(int argc, const char ** argv) {
char *fName = "t.dat";
int i, r;
double d;
id aFile;
initSwarmApp(argc, argv,"1.3", "address@hidden");
if ( !(aFile = [InFile create: globalZone withName: fName]) ) {
printf( "\nNo file named '%s' to read from!\n", fName );
return( -1 );
}
printf("\nReading from file '%s':\n", fName );
for ( i = 0; i < 3; ++i ) {
d = -1;
r = [aFile getDouble: &d];
printf( "r is %d, d is %f.\n", r, d );
}
printf("Done reading from file '%s'.\n", fName );
[aFile drop];
return( 0 );
}
Here is t.dat:
address@hidden InputOutput]$ cat t.dat
32 xx 33
Here is the output from running the program:
--------------
address@hidden InputOutput]$ ./io
Reading from file 't.dat':
r is 1, d is 32.000000.
r is 1, d is -1.000000.
r is 1, d is -1.000000.
Done reading from file 't.dat'.
---------------
Am I missing something obvious here?
Why doesn't getDouble return 0 when it hits the xx ?
The doc says "In case of failure, the method returns 0."
What is considered a failure? Just EOF?
In any case, I think the ref page for InFile should be
fixed up a bit, to explain what is failure, to note that
these will skip whitespace to get to the next token, etc.
- r
ps this is Swarm-1.4.
Rick Riolo address@hidden
Program for Study of Complex Systems (PSCS)
4477 Randall Lab
University of Michigan Ann Arbor MI 48109-1120
Phone: 734 763 3323 Fax: 734 763 9267
http://www.pscs.umich.edu/PEOPLE/rlr-home.html
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
- Is this a Bug in InFile getDouble (& other InFile get* methods)?,
Rick Riolo <=