![]() | Programming Guide | ![]() |
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_namefield_number- The field to receive
value.element- The element in
field_nameto receivevalue.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.
C only
sm_dtofieldconverts the real numbervalueto user-readable format as specified by format. It then moves this value into the specified field with a call to sm_amt_format. If theformatstring is empty and the field'sdata_formattingproperty is set toPV_NUMERIC, Panther uses the field's numeric formatting subproperties to determine precision. Ifdata_formattingis set toPV_NONE, Panther uses the precision set by the behavior variableDECIMAL_PLACES.You can round the number of decimal places to
nplaces with the format string"%.nf". To truncate, use the format string"%t.nf".
/* 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");