2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
5 Desc: Convert a string into a long
9 /*****************************************************************************
12 #include <proto/dos.h>
14 AROS_LH2I(LONG
, StrToLong
,
17 AROS_LHA(CONST_STRPTR
, string
, D1
),
18 AROS_LHA(LONG
*, value
, D2
),
21 struct DosLibrary
*, DOSBase
, 136, Dos
)
24 Convert a string to a long number.
27 string - The value to convert
28 value - The result is returned here
31 How many characters in the string were considered when it was
32 converted or -1 if no valid number could be found.
35 The routine doesn't check if the number if too large.
38 // Valid number are: 5, -1, +3, +0007, etc.
46 *****************************************************************************/
51 CONST_STRPTR s
=string
;
53 /* Skip leading whitespace characters */
54 while(*s
==' '||*s
=='\t')
61 /* If there is no number return an error. */
68 /* Calculate result */
71 while(*s
>='0'&&*s
<='9');