/ api / name / gb.numberfromstring
GB.NumberFromString
Syntax

    int GB.NumberFromString ( int option , const char *str , long len , GB_VALUE *value );

Reads a number inside a string and returns it in a GB_VALUE structure.

- option is a combination of the following constant :
  - GB_NB_READ_INTEGER to read an Integer.
  - GB_NB_READ_LONG to read a Long.
  - GB_NB_READ_INT_LONG to read an Integer or a Long.
  - GB_NB_READ_FLOAT to read a Float floating point number.
  - GB_NB_READ_ALL to read any number.
  - GB_NB_READ_HEX_BIN to allow reading hexadecimal or binary values.
  - GB_NB_LOCAL to use localisation settings.
- str is the address of the string.
- len is its length.
- value points to a GB_VALUE structure that will receive the result of the conversion.

This function returns a non-zero value if nothing could be read inside the specified string.

- If the string contains an Integer, the type field of the GB_VALUE structure is set to GB_T_INTEGER, and you can cast this structure to a GB_INTEGER to get the value.
- If the string contains a Long, the type field of the GB_VALUE structure is set to GB_T_LONG, and you can cast this structure to a GB_LONG to get the value.
- If the string contains a floating point number, the type field of the GB_VALUE structure is set to GB_T_FLOAT, and you can cast this structure to a GB_FLOAT to get the value.

### See also

Conversion Functions