home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / Libraries / Icon / c / SetDouble < prev    next >
Encoding:
Text File  |  1994-05-29  |  770 b   |  27 lines

  1. #include "Wimp.h"
  2. #include "WimpSWIs.h"
  3. #include "Icon.h"
  4.  
  5. #include <stdio.h>
  6. #include "string.h"
  7.  
  8.  
  9. extern void Icon_SetDouble(window_handle w, icon_handle i,
  10.                            double value, int decimalplaces)
  11. /*
  12.  * Sets the given icon's text to hold the number in "value". (and redraws icon)
  13.  * After the decimal place, up to "decimalplaces" digits will be printed
  14.  * If the number is too big (too many digits), it will be truncated to fit
  15.  * (which may completely destroy the value you wished to represent, or
  16.  * just reduce its accuracy)
  17.  * If unable to set the text (incorrect icon type), it returns quietly
  18.  */
  19. {
  20.   char       text[32], format[16];
  21.  
  22.   sprintf(format, "%%.%df", decimalplaces);
  23.   sprintf(text, format, value);
  24.  
  25.   Icon_SetText(w, i, text);
  26. }
  27.