>-----Original Message-----
>From: Patrick Ouellet [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, July 13, 2000 11:39 AM
>To: Palm Developer Forum
>Subject: Low Memory access error
>
>
>Ok I had the "MyApps" 1.0 has just read
>directly from NULL (memory location zero)
>
>I know what it mean, but I want to know to to solve this problem...
>What am I doing wrong.
>
>These are my global variable:
>
>UInt CurChar = 0;
>CharPtr TempCode[5];
Make this: Char TempCode[5];
>
>This is my code:
>
>static Boolean MainFormHandleEvent(EventPtr eventP)
>{
> Boolean handled = false;
> FormPtr frmP;
>
> switch (eventP->eType)
> {
> case ctlSelectEvent:
> {
> switch(eventP->data.ctlEnter.controlID)
> {
> case MainBtnStarButton:
> FrmCustomAlert(TestAlertAlert, *TempCode, NULL, NULL);
> break;
>
> case MainBtnToeButton:
> StrCopy(*TempCode, "");
> CurChar = 0;
> break;
Basically, *TempCode is a pointer to a pointer to a string.
you can ditch that. What you need to do is do a StrLen test
on TempCode. If the value at TempCode[0] == '\0', Then do
a StrCopy. Else, do a StrCat. You'd want to do this:
if ( StrLen( TempCode ) < 1 )
StrCopy( TempCode, "0" );
else
StrCat( TempCode, "1" );
in each of your case statements. This way, you don't have to
copy a null character into TempCode. I do these number pads all
the time. =)
> case MainBtn0Button:
> StrCat(*TempCode, "0");
> CurChar++;
> break;
>
> case MainBtn1Button:
> StrCat(*TempCode, "1");
> CurChar++;
> break;
>
> case MainBtn2Button:
> StrCat(*TempCode, "2");
> CurChar++;
> break;
>
> case MainBtn3Button:
> StrCat(*TempCode, "3");
> CurChar++;
> break;
>
> case MainBtn4Button:
> StrCat(*TempCode, "4");
> CurChar++;
> break;
> }
>
> handled = true;
>
>
> if (CurChar == 4)
> {
> FrmCustomAlert(TestAlertAlert, "4 Char", NULL, NULL);
> }
> break;
> }
You might want to put together an alert resource in Constructor.
Just a thought...then you'd just have to write: FrmAlert( TestAlert );
> case menuEvent:
> return MainFormDoCommand(eventP->data.menu.itemID);
>
> case frmOpenEvent:
> frmP = FrmGetActiveForm();
> MainFormInit( frmP);
> FrmDrawForm ( frmP);
> handled = true;
> break;
Put some brackets in these...just a good style thing, you know,
for any statement that nests more than 2 calls or statements. =)
>
> default:
> break;
>
> }
> return handled;
>}
Hope that helps!
-Rus
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/