Programming Guide



sm_*strip_amt_ptr

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 to NULL. For example, this JPL statement puts the unformatted contents of field sale_amt into variable amt:
vars amt
amt = sm_n_strip_amt_ptr("sale_amt", @NULL)

If inbuf contains the string to strip, supply this parameter with an argument of NULL.

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 into amt:
amt = sm_strip_amt_ptr(@NULL, "$123,489.12")

To use the data in field_name/field_number, supply NULL.


Returns

Description

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 for inbuf 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's SM_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.

See Also

sm_amt_format, sm_dblval