I am trying to make a form that will take two
TextFields and add them out and display the total on
the form for the user to see. On the button client I
call the following code. Will I cant get the total to
display and I also fell that someone most know a
better way to get the data from the TextField. If you
can help please email me at [EMAIL PROTECTED]

static void DoMath()
{
         FormPtr   form = FrmGetActiveForm();
         FieldPtr  field;
        
         MemHandle  h;
         Char* s1;
         Char* s2;
                                         
         Int32 number1;
         Int32 number2;
         Int32 total;
                                         
                                        
        // Checking field 1             
        field = (FieldPtr)FrmGetObjectPtr(form,
FrmGetObjectIndex(form,MainField1Field));
        h = FldGetTextHandle(field);
        if (h)
        {
                s1= (Char*)MemHandleLock(h);
                while(*s1 != '\0')
                {
                        if(*s1 >= 'A' && *s1 <= 'Z' || *s1 >= 'a' && *s1 <=
'z')
                                StrCopy(s1, s1+1);
                        else
                                s1++;
                                
                }
                
                MemHandleUnlock(h);
                //
                // Does anyone know a way around this??
                //
                s1= (Char*)MemHandleLock(h);
                number1  = StrAToI(s1);
                MemHandleUnlock(h);
                FldSetTextHandle(field, NULL);
                FldDrawField(field);
         }
                

         // Checking field 2            
     field = (FieldPtr)FrmGetObjectPtr(form,
FrmGetObjectIndex(form,MainField2Field));
         h = FldGetTextHandle(field);
     if (h)
     {
                s2= (Char*)MemHandleLock(h);
                while(*s2 != '\0')
                {
                        if(*s2 >= 'A' && *s2 <= 'Z' || *s2 >= 'a' && *s2 <=
'z')
                                StrCopy(s2, s2+1);
                        else
                                s2++;
                                
                }

                MemHandleUnlock(h);
                s2= (Char*)MemHandleLock(h);
                number2  = StrAToI(s2);
                MemHandleUnlock(h);
                FldSetTextHandle(field, NULL);
                FldDrawField(field);
         }
         

        total = number1 + number2;
        field = (FieldPtr)FrmGetObjectPtr(form,
FrmGetObjectIndex(form,MainTotalField));
        FldSetTextHandle(field, h);
        s2= (Char*)MemHandleLock(h);
        StrCopy(s2, (Char*)total);
        MemHandleUnlock(h);             
        FldDrawField(field);
}


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to