Hi, All
I have two different fields in the form.  One of them is for PC date, and
another one is for PC time. The first field for PC date works fine, and it
shows the correct PC date in the field. However, when I try to use the same
way to set the PC time, it won't work. It keeps telling me the "starter
write into the lower memory.....". Anyone can show me what is wrong with my
code?

switch (event->eType) 
        {
        case frmOpenEvent:
                FrmDrawForm(form);
                handled = 1;
                do_datetime();
                
                        PrefGetPreferences (&sysPrefs);
                        
                        //Get the date formats from the system preferences
                        LongDateFormat = sysPrefs.longDateFormat;
                        ShortDateFormat = sysPrefs.dateFormat;
                        
                        
                        //Get today's date
                        TimSecondsToDateTime (TimGetSeconds (), &dateTime);
                        Date.year = dateTime.year + 20;
                        Date.month = dateTime.month;
                        Date.day = dateTime.day;
                        
                        years = Date.year;
                        months = Date.month;
                        days = Date.day;
                        
 
DateToAscii(months,days,years,ShortDateFormat,(CharPtr)pString);
          //print date to the PC time/date field
                fieldptr_datetime_date = FrmGetObjectPtr(form,
FrmGetObjectIndex(form, fieldID_datetime_date));
                FldSetTextPtr(fieldptr_datetime_date, pString);
                FldRecalculateField(fieldptr_datetime_date, true);
//The following code for showing the correct time in the field.
 But it won't work .                    
                //Get the time formats from the system preferences
                TimeFormat = sysPrefs.timeFormat;
                
                //Get Current time
                TimSecondsToDateTime(TimGetSeconds(), &dateTime);
      
                seconds = dateTime.second;
                minutes = dateTime.minute;
                hours = dateTime.hour;
                
                                
                TimeToAscii(hours, minutes,TimeFormat, (CharPtr)tString);
                // print the time to the PC time/date field
                fieldptr_datetime_date = FrmGetObjectPtr(form,
FrmGetObjectIndex(form, fieldID_datetime_time));
                FldSetTextPtr(fieldptr_datetime_time, tString);
                FldRecalculateField(fieldptr_datetime_time, true);
                
                
                break;
}

Another question anout thime. Anyone can tell me which function I can use
for show the second in the time field ?

thank you for any explanation.

allen

Reply via email to