STAB_GetElemByFloat

The STAB_GetElemByFloat function returns a string stored with a specific float value in a STAB object.

extern STAB_GetElemByFloat
  float handle         // handle to STAB
  float searchval      // search value
  stringvar strdata$   // string variable to receive matching string
  floatvar index       // float variable to receive matching string's index

Parameters

handle
[in] Handle to a STAB object previously returned from STAB_Create.
value
[in] The associated value to find in the STAB object.
strdata$
[out] The string variable that will be set with the first string that has an associated float value of searchval.
index
[out] The float variable that will be set with the index of the matching string, or -1 if a match was not found.

Remarks

If handle is not a valid STAB handle, an error message will be printed to the console.

STAB_GetElemByFloat compares the value of searchval with each string's associated float value. It returns the first matching index, if one exists.

To perform a search that matches associated values rounded to the nearest integer, use STAB_GetElemByInt.

Example

extern STAB_Create handle
extern STAB_Append handle "a" 0.3
extern STAB_Append handle "b" 1.5
extern STAB_Append handle "c" 2.1
extern STAB_GetElemByInt handle 1.5 str$ idx

At the end of this code fragment, str$ will have a value of "b" and idx will have a value of 1.