wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/Weight/FormatWt

Version 2 (modified by Don Wilson, 3 years ago) ( diff )

--

FormatWt

Format a string representation of the specified weight

string FormatWt(float fWt, uint8 byIntv, uint8 byDec, int nLen = 7);

char* FormatWt(float fWt, uint8 byIntv, uint8 byDec, char* pszWt, int nLen = 7);

Parameters

  • fWt - weight value to format
  • byIntv - interval such as 20 for twenty pound intervals.
  • byDec - number of decimal places.
  • nLen - length to format the string, spaces will be padded to the left.
  • pszWt - buffer to copy weight data to.

Return Value

  • Returns the string formatted weight. char* return override returns a pointer to the passed pszWt parameter where the result is stored.

Remarks

This will format the provided weight value into appropriate divisions and add zeros for zero weight if necessary based on the interval. For example, for interval of 20 lb is specified and the weight is zero the output will be " 00". The value returned is from an internal memory buffer from the last MnBdRead that received a weight for the specified scale. An application program should be structured properly for this data to be updated when needed.

For USA applications the interval should be a multiple of 1, 2, or 5. For example the interval may be 1, 2, 5, 10, 20, or 50. If the interval is multiple digits such as 10 the decimal place parameter must be zero.

Examples

float wt = 12055;
string strWt = FormatWt(wt, 20, 0);
DisplayText(0, 0, strWt);
// Will display 12060
float wt = 12055;
char szWt[20];
FormatWt(wt, 20, 0, szWt);
DisplayText(0, 0, szWt);
// Will display 12060

See Also

Note: See TracWiki for help on using the wiki.