Thanks, it worked.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Luciano A.
Stertz
Sent: Thursday, September 16, 2004 3:37 PM
To: Palm Developer Forum
Subject: Re: help on integer to string conversion
Prototype
Char *StrIToA (
Char *s,
Int32 i
)
Parameters
← s
Pointer to a string of size maxStrIToALen in which to store the
results.
→ i
Integer to convert.
char * size = "12";
strDisplay = StrIToA (size,display);
======================
Jim,
As the above text states, the first parameter in StrIToA is a char
pointer with at least maxStrIToALen bytes, that will receive the
converted string. The char pointer you are
passing has only 3 bytes ("12\0"). Try to create it as follows:
char size[maxStrIToALen];
If it doesn't compile, you may need to allocate the memory
dinamically:
char *size = MemPtrNew(maxStrIToALen);
Don't forget to call MemPtrFree later to free the memory.
strDisplay will only receive a pointer to the buffer, so you don't
need
to initialize it.
Try:
char *strDisplay;
instead of:
char * strDisplay = "this is a test";
Luciano Stertz
Jim Coburn wrote:
> Luciano,
>
>
> I get a different memory location but the same effect if I try to cast
> 'display" as a char * in the line from CtlGetValue.
>
> The function code is as follows:
>
> Boolean MainFormDoCommand(UInt16 command)
> {
> Boolean handled = false;
>
> //get the Main form pointer
> FormType * frmP = FrmGetActiveForm();
>
> //set up slider
> ControlType * sldPtr;
> char * size = "12";
> char * strDisplay = "this is a test";
> int display;
>
> //set up field
> FieldType *field;
> UInt16 fieldIndex;
>
>
> ...
> case MainInputSlider:
>
> sldPtr = FrmGetObjectPtr(frmP,
> FrmGetObjectIndex(frmP,MainInputSlider));
> display = (long)CtlGetValue(sldPtr);//returns the
> value of the slider
>
> strDisplay = StrIToA (size,display);
>
> fieldIndex = FrmGetObjectIndex(frmP,
> MainOutputField);
> field = (FieldType *)FrmGetObjectPtr(frmP,
> fieldIndex);
> FrmSetFocus(frmP, fieldIndex);
>
>
>
> FldInsert(field,strDisplay,StrLen(strDisplay));
>
> handled = true;
> break;
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/