Sometimes you would like to have the current date displayed in a date field when the form is displayed. To get the date from the operating system, call the date_get() function:
|
Caution: You must allocate memory for date_stp before calling date_get().
The specifics for using a date field are summarized below:
| Field Type | F_DATE |
| Header File | vv_date.h |
| Data Variable | UCHAR *data or UCHAR data[ ]
The data variable must be allocated and initialized. The variable must be long enough to hold the date string entered in the field, including separators and a null terminator, or memory will be corrupted. |
| Picture Control | You can create a picture that has controlled format entry or one that allows free-format entry.
When defining a picture string for controlled date entry, the picture string must match the date format. The picture control characters 9, U, A, *, and ! are allowed in the picture. For instance, if the date format is "DD-SSS-YYYY", the picture should be "UU-AAA-UUUU" or "UU-!!!-UUUU". For free-format date entry, specify a string of Xs for the picture string. Users can then enter the date using their choice of separators. The only limitation is that the user must enter the day, month, and year as specified in the format string. The system will attempt to convert the entered date into the date format specified for the field. |
| Code Example | UCHAR *date, *my_format;
my_format = "DD-SSS-YYYY"; date_get(date, my_format); fldp = fld_def(5, 1, "Order Date: ", FBELOW, sf_datefmt(my_format, fldp); |