I am trying to build a database with my program
creatorid and the time it was first run and then each
time the program is run I would like to check the
database again to see if its pass the 30 day mark
(will in the test 50 sec's). Can you please look at
this code and tell me why its not working

struct jsShareware
{
        UInt32 name;    
        UInt32 number;  
};

static int getShareWareCounter(UInt32 creatorID)
{
                DmOpenRef            dbRef;
                int foundProgram = false;
              UInt32 timeInSeconds;
                UInt32 rCount;

                timeInSeconds = TimGetSeconds ();               
                dbRef = OpenSharewareDatabase(SHDBNAME, SHCREATORID,
SHDBTYPE, CREATORID);
                
                rCount = DmNumRecords(dbRef);
                for(int i = 0; i < rCount;i++)
                {
                        MemHandle h = DmQueryRecord( dbRef, i);
                        jsShareware *rec = (jsShareware *) MemHandleLock(
h );
                        
                        if(rec->name == creatorID)
                        {
                           if(timeInSeconds >= rec->number)
                           {
                                 return false;
                           }
                           else
                           {                                            
                                  return true;
                           }  
                        }
        
                        MemHandleUnlock( h );
                }
                if(foundProgram == false)
                {
                        MemHandle h = DmNewRecord( dbRef, 0, sizeof(
jsShareware ) );
        
                    jsShareware *rec = (jsShareware *)
MemHandleLock( h );
                    jsShareware tempRecord;

                        
                 // 50 seconds test
            timeInSeconds= timeInSeconds + 50;
                        
                    tempRecord.name = creatorID;
                    tempRecord.number = timeInSeconds;

                    DmWrite (rec, 0, &tempRecord, sizeof
(tempRecord));
                    MemHandleUnlock( h );
                    DmReleaseRecord( dbRef, 0, true );             
          

                }

                DmCloseDatabase(dbRef);
                
                return true;
}

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.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