dude, you already answered this question yourself on the newsgroup several
days ago.
-- snip --
> // 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
right here is your problem. you cut and pasted, and forgot to update it, so
you're setting fieldptr_datetime_date when you really mean to set
fieldptr_datetime_time. you later use fieldptr_datetime_time but it's
uninitialized. that's very easy to discover if you step thru your code in a
debugger. (my mantra: use debugger, use debugger, use debugger...).
> fieldptr_datetime_date = FrmGetObjectPtr(form,
> FrmGetObjectIndex(form, fieldID_datetime_time));
> FldSetTextPtr(fieldptr_datetime_time, tString);
> FldRecalculateField(fieldptr_datetime_time, true);
and as pointed out in previous e-mails on this newsgroup, you're missing
FldDrawField here, so it won't update anyway.
----- Original Message -----
From: Allen Yang <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 02, 1999 12:25 PM
Subject: How to show time in the proper field in the form?
> 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);
>
> file://Get the date formats from the system preferences
> LongDateFormat = sysPrefs.longDateFormat;
> ShortDateFormat = sysPrefs.dateFormat;
>
>
> file://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);
> file://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);
> file://The following code for showing the correct time in the field.
> But it won't work .
> file://Get the time formats from the system preferences
> TimeFormat = sysPrefs.timeFormat;
>
> file://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
>