Best way to create a DATE?

  • I'm using WPTools to allow my users to define templates that they later use for printing in a mail merge process. When designing the templates, I need to allow the user to drop an object onto the document to represent the current date (not the date that the DATE object is created but one that can auto-update to reflect the current date when the user prints the template).

    Using code similar to the following:
    WPRichText1.ActivePar.InsertNewObject(0, wpobjTextObject, False, False, WPRichText1.WritingAttr.CharAttr).Name := WPTextFieldNames[wpoDate];

    I can create an object that immediately displays today's date (08/05/09).

    Question #1
    Since the date was created as a TextObject rather than as literal text, I assume that when I save my template and recall it next month (say on September 1st), the date object will report the value 09/01/09. Am I correct in this assumption?

    Question #2
    When I print the template, in addition to the document being sent to the printer, I have to archive it to a database table so the user can review it at a later date. For historical accuracy, I have to display the archived document EXACTLY as it was printed, thus I need the DATE object to retain the date it reported when it was initially printed. So essentially at this point I need the DATE object NOT to automatically update itself.
    What would be the best way for me to accomplish this? Is there some object type that reacts to an event, like a merge variable, that I could simply write an event handler for to control the date's display?

  • I really hate to come across sounding dense, but I cannot find this method anywhere. Not in any of your source code and not in the docs.

    The closest name I can find is InputTextFieldName. Is this what you meant by any chance? If not, where can I find InsertTextObjectName?

    Also, InputTextFieldName seems to support an optional alias passed in a FieldMask property that gets mapped to the TextObj.Source property. By default, the field mask does not appear to be used. If I wanted to create a date on a document template that simply displayed the word DATE on screen until printed I assume I should be able to pass the word DATE to the FieldMask property. To make DATE appear, should I then be adding code to OnTextObjectGetText to read TextObj.Source and display that instead of the date value?

    • Offizieller Beitrag

    Hi,

    InsertTextObjectName is what I meant.

    Zitat

    To make DATE appear, should I then be adding code to OnTextObjectGetText to read TextObj.Source and display that instead of the date value?

    You can use a different field name, then You can format the date yourself.

    Otherwise use @... :
    @mm/dd/yyyy

    in "Source". This is handled internally
    --

    To lock the time and date You can use the
    flag wpLockDATEandTIME

    in WPRichTExt1.HeaderFooter.RTFViewOptions

    Julian

  • Thanks for the tips on date handling.

    Would you be so kind as to direct me to where this InsertTextObjectName method might be located? The unit its in or the class to which it belongs?

    I have things basically working as I wanted using the other method I asked you about but I would prefer to do things the right way...