Programming Guide



sm_*dtofield

Writes a real number to a field

int sm_dtofield(int field_number, double value, char *format);
int sm_e_dtofield(char *field_name, int element, double value, char *format);
int sm_i_dtofield(char *field_name, int occurrence, double value, char *format);
int sm_n_dtofield(char *field_name, double value, char *format);
int sm_o_dtofield(int field_number, int occurrence, double value, char *format);

field_name
field_number
The field to receive value.

element
The element in field_name to receive value.

occurrence
The occurrence in the field to receive value.

value
The real number data to write.

format
Specifies the format to apply to value. To supply a value of 0, cast the argument as follows: (char *)0.

Environment

C only

Returns

Description

sm_dtofield converts the real number value to user-readable format as specified by format. It then moves this value into the specified field with a call to sm_amt_format. If the format string is empty and the field's data_formatting property is set to PV_NUMERIC, Panther uses the field's numeric formatting subproperties to determine precision. If data_formatting is set to PV_NONE, Panther uses the precision set by the behavior variable DECIMAL_PLACES.

You can round the number of decimal places to n places with the format string "%.nf". To truncate, use the format string "%t.nf".

Example

/* Place the value of pi on the screen, using the
* formatting attached to the field. */

sm_n_dtofield("pi", 3.14159, (char *)0);

/* Do it again, using only three decimal places.
sm_n_dtofield("pi", 3.14159, "%5.3f");

See Also

sm_amt_format, sm_dblval