Programming Guide |
Strips non-digit characters from a string
char *sm_strip_amt_ptr(int field_number, char *inbuf);char *sm_e_strip_amt_ptr(char *field_name, int element, char *inbuf);char *sm_i_strip_amt_ptr(char *field_name, int occurrence, char *inbuf);char *sm_n_strip_amt_ptr(char *field_name, char *inbuf);char *sm_o_strip_amt_ptr(int field_number, int occurrence, char *inbuf);
field_name, field_number
- The field with the string to strip. You must also set parameter
inbuf
toNULL
. For example, this JPL statement puts the unformatted contents of fieldsale_amt
into variableamt
:vars amt
amt = sm_n_strip_amt_ptr("sale_amt", @NULL)If
inbuf
contains the string to strip, supply this parameter with an argument ofNULL
.element
- The element with the string to strip.
occurrence
- The occurrence with the string to strip.
inbuf
- Contains the string to strip. For example, this JPL statement strips the supplied string of its currency symbol and comma and puts
123489.12
intoamt
:amt = sm_strip_amt_ptr(@NULL, "$123,489.12")To use the data in
field_name
/field_number
, supplyNULL
.
- · A pointer to a string that contains the stripped text.
- · 0 if
inbuf
is set toNULL
and the field number is invalid.
sm_strip_amt_ptr
strips all leading zeros and non-digit characters from the string, except for an optional leading minus sign and decimal point. If you supply a value forinbuf
sm_strip_amt_ptr
processes its contents. Otherwise, it uses the field data.This function identifies the decimal character to preserve from the widget's decimal_symbol property. If this property is not set,
sm_strip_amt_ptr
uses the character that is set by the message file'sSM_DECIMAL
entry (refer to "Decimal Symbols" in Application Development Guide).Note:
sm_strip_amt_ptr
stores its return value in a pool of buffers that it shares with other functions. Consequently, you should use this data immediately.