Appendix A: System Routines — EStack Utilities
523
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
estack_to_ushort
Declaration:
short
estack_to_ushort
(EStackIndex
i
, unsigned short *
result
)
Category(ies):
EStack Utilities, EStack Arithmetic
Description:
Converts a tagged whole number to a C unsigned short.
Inputs:
i
— Index of the tag of a tagged integer or tagged float whole
number.
result
— Points to an unsigned short for return value.
Outputs:
If successful, returns 1 and unsigned short via
result
. If the argument is a
valid type, but too large for unsigned short, returns 0 and stores 65535 in
result
. If the argument is invalid, returns
L
1 and stores 0 in
result
.
Assumptions:
None
Side Effects:
None
Availability:
On AMS 1.05 and higher.
TI
-
89 / TI
-
92 Plus
Differences:
None
See Also: estack_to_short
Example:
void push_char (EStackIndex i)
/* i indexes a tagged whole number from 0 through 255 or an aggregate thereof.
Pushes the corresponding string or aggregate thereof, except char(0) -> "".
*/
{ unsigned short c;
if (IS_NUMBER_TAG(ESTACK(i)) && is_whole_number(i) &&
1 == estack_to_ushort(i, &c) && c < 256 )
{ push_quantum (0);
if (c)
push_quantum ((Quantum) c);
push_quantum (0u);
push_quantum (STR_DATA_TAG);
}
else if (LIST_TAG == ESTACK(i))
{ map_tail (push_char, i-1);
push_quantum (LIST_TAG);
}
else ER_THROW (ER_DOMAIN);
}