In all the discussion about displaying the build date/time, I didn't see anybody mention that you should use the formats specified by the user.

Which means that The Right Thing to do is to store the build date as a soft constant (tint) with an ID >= 1000, then use the DateTime.h routines to format it properly. So for PilRC that means implementing __TIME__ (or whatever) as something that generates the build date as a Palm OS seconds since 1904 value.

I don't know if .rc files have the same issue as using .r files with CodeWarrior, in that what I want is for the file to be recompiled every time I regenerate the .prc, not just when the IDE thinks that it needs to happen. Currently I need to use an external script to force this to work properly.

Anyway, the approach I use (with Rez) is as follows:

1. Create a .r file with:

#include "UIResDefs.r"

resource 'wrdl' (1000)
{
        {
                $$Year,
                $$Month,
                $$Day,
                $$Hour,
                $$Minute
        }
};

2. In the code:

// Word list resource from the xx.r file, and indexes into it.
const DmResID BuildDateWordList = 1000;
enum
{
        iBuildYear = 0,
        iBuildMonth,
        iBuildDay,
        iBuildHour,
        iBuildMinute
};

and

        Char buildDate[dateStringLength + 1];
        DateToAscii(PU_GetIndexedUInt16(BuildDateWordList, iBuildMonth),
                PU_GetIndexedUInt16(BuildDateWordList, iBuildDay),
                PU_GetIndexedUInt16(BuildDateWordList, iBuildYear),
                (DateFormatType)PrefGetPreference(prefDateFormat),
                buildDate);

        Char buildTime[timeStringLength + 1];
        TimeToAscii(PU_GetIndexedUInt16(BuildDateWordList, iBuildHour),
                PU_GetIndexedUInt16(BuildDateWordList, iBuildMinute),
                (TimeFormatType)PrefGetPreference(prefTimeFormat),
                buildTime);

where PU_GetIndexedUInt16 just loads the requested (by index) value from the word list resource. Then in the code I load up the version string resource (the tver=1000) and finally...

        // Load "Version ^0 (^1 ^2)"
        Char templateStr[32];
        SysCopyStringResource(templateStr, VersionTemplateString);

        Char* versStr = TxtGlueParamString(templateStr,
                                        versP,
                                        buildDate,
                                        buildTime,
                                        NUL);

FormType* frmP = FrmInitForm(AboutForm);

FieldType* fldP = (FieldType*)FrmGetObjectPtr(frmP,

        FrmGetObjectIndex(frmP, AboutVersionField));
        FldSetTextPtr(fldP, versStr);
        FldRecalculateField(fldP, true);

I know, what a pain...

-- Ken

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

Reply via email to