anachronox-sdk/docs/stab/stab_getelem.html
2002-01-21 00:00:00 +00:00

80 lines
2.4 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>STAB_GetElem</TITLE>
<META name="Author" content="Joey">
<LINK rel="stylesheet" type="text/css" href="../webdocs.css">
</HEAD>
<BODY>
<H1><A name="ape_stab_getelem"></A>STAB_GetElem</H1>
<P>The <B>STAB_GetElem</B> function returns a string stored at
a specific index in a STAB object.</P>
<PRE class="syntax">
<B>extern STAB_GetElem</B>
<B> float</B> <I>handle</I> // handle to STAB
<B> float</B> <I>index</I> // index to data
<B> stringvar</B> <I>strdata$</I> // string variable to receive string
<B> floatvar</B> <I>fltdata</I> // (optional) float variable to receive associated data
</PRE>
<H4>Parameters</H4>
<DL>
<DT><I>handle</I></DT>
<DD>[in] Handle to a STAB object previously returned from <A
href="stab_create.html"><B>STAB_Create</B></A>.</DD>
<DT><I>index</I></DT>
<DD>[in] The zero-based index of the string to retrieve.</DD>
<DT><I>strdata$</I></DT>
<DD>[out] The string variable that will be set with the
string stored in the STAB object specified by <I>handle</I>
and <I>index</I>.</DD>
<DT><I>fltdata</I></DT>
<DD>[out] The float variable that will be set with the
optional data associated with the string when it was added to
the STAB object.</DD>
</DL>
<H4>Remarks</H4>
<P>If <I>handle</I> is not a valid STAB handle, an error
message will be printed to the console. If <I>index</I> is not
at least zero and strictly less than the value returned from <A
href="stab_getsize.html"><B>STAB_GetSize</B></A>, an error
message will be printed to the console. For example, if the
array size is 10, then the possible values of <I>index</I> is
between 0 and 9.</P>
<P>If there was no optional float value specified when the
string was added to the STAB object, <I>fltdata</I> will have a
value of zero.</P>
<H4>Example</H4>
<P>The following code fragment demonstrates how to use a loop
to retrieve every element in a STAB object.</P>
<PRE>
// Assume @handle is already initialized to
// a STAB object with data in it.
extern STAB_GetSize @handle @size
@i = 0
while (@i &lt; @size)
{
STAB_GetElem @handle @i @str$
// Do something useful with the string.
}
</PRE>
</BODY>
</HTML>