At 10:11 AM 7/20/99 +0100, you wrote:
>where 'tele_input.battery_charge' is defined as a UInt, and it running
>through a '%d' in a StrPrintF to convert it back to characters for the
>display. 'packet' is a character string.
>
>What do you make of it?
Hi Stuart,
The short answer is that you are passing the wrong format specifier to
StrPrintF. %d and %i indicate signed integers. For unsigned you need to
use %u.
The long answer is that StrPrintF takes a variable argument list. This
means that you can pass absolutely any variables you want to this function,
and the compiler will gladly push them onto the stack. StrPrintF decodes
the format string and pops the variables back off the stack depending on
what it expects.
For example.
Let's say we want to format a string (stringP) and an integer (value) into
an output string (outputP). We would call:
CStrPrintF (outputP, "%s %i", stringP, value);
If we wanted to format value as an unsigned integer, we'd call:
CStrPrintF (outputP,. "%s %u", stringP, value);
It does not matter that value is a signed rather than unsigned integer.
StrPrintF has no idea of what the original declaration is - it just knows
what it has been told to expect. And it expects it. If you pass a float,
a character string, a void pointer, whatever, it will pop the argument off
as an integer and format it as such.
If you want an even longer explanation, e-mail me off list.
Hope this helps.
Greg
Greg Winton
Bachmann Software and Services, LLC
mailto:[EMAIL PROTECTED]
http://www.bachmannsoftware.com
Software Development for Handheld & Mobile Computing, Windows and the Internet
Home of Bachmann Print Manager, the only graphical printing solution for
the Palm Computing Platform