atobasic - convert string to numeric value


#include <basic/type.h>

int atobasic(ps, type, pi, pd)
char **ps;
int type;
short *pi;
double *pd;


Atobasic converts a null-terminated string, *ps, into a numeric value.  If the string is converted to an integer, the value is stored in *pi.  If the string is converted to floating point, the value is stored in *pd

The string is read in the format of BASIC numeric constants.  Characters are read and converted until the format is violated or the end of the string is reached.  *Ps is updated to this ending location and so may be used to determine the validity of the string. 

Type is normally zero.  This function is also used by the BASIC lexical analyzer to convert constants in the source code where type identifies the explicit type marker of the constant (see generic(inc)). 

This function returns the type (see generic(inc)) of the converted value.  The type is determined from type and the format of the string. 

This function supports functions which require string conversion.  It does not directly implement any BASIC functions. 


input(io), val(cvt)


Zero is returned on overflow.  A type is returned and a zero value is produces on underflow; this is not an error. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber