|
1
|
/**
|
|
2
|
Program Purpose:
|
|
3
|
- To determine how OpenEdge modifies the FORMAT attribute of a DATE variable when set, depending on the SESSION:DATE-FORMAT value.
|
|
4
|
|
|
5
|
Program Requirements:
|
|
6
|
- Define a DATE variable named 'd' with no initial value.
|
|
7
|
- Iterate over a list of valid SESSION:DATE-FORMAT values: mdy, dmy, ymd, myd, dym, ydm.
|
|
8
|
- For each SESSION:DATE-FORMAT value:
|
|
9
|
- Set SESSION:DATE-FORMAT to the current value.
|
|
10
|
- Set the format of 'd' to each of: 99/99.9999, 9999-99.99, 9999-9999.9999.
|
|
11
|
- Display the current SESSION:DATE-FORMAT, the format just set, and the applied FORMAT of 'd', ensuring the character format length is large enough to fit the result line.
|
|
12
|
- Use a frame to contain 'd' for UI operations, without specifying a default format in the frame, and ensure the frame is wide enough to fit the output lines.
|
|
13
|
- Adjust the DEFAULT-WINDOW size to be wide enough to accommodate the frame and output lines.
|
|
14
|
- Save
|
|
15
|
*/
|
|
16
|
|
|
17
|
/* Adjust the DEFAULT-WINDOW size */
|
|
18
|
DEFAULT-WINDOW:WIDTH-CHARS = 65.
|
|
19
|
DEFAULT-WINDOW:HEIGHT-CHARS = 15.
|
|
20
|
|
|
21
|
/* Define the DATE variable without an initial value */
|
|
22
|
DEFINE VARIABLE d AS DATE NO-UNDO.
|
|
23
|
|
|
24
|
/* Define a frame for the variable, wide enough for output */
|
|
25
|
DEFINE FRAME myFrame
|
|
26
|
d
|
|
27
|
WITH NO-LABELS NO-BOX DOWN SIZE 62 BY 10.
|
|
28
|
|
|
29
|
/* List of valid SESSION:DATE-FORMAT values */
|
|
30
|
DEFINE VARIABLE dateFormats AS CHARACTER NO-UNDO EXTENT 6
|
|
31
|
INITIAL ["mdy", "dmy", "ymd", "myd", "dym", "ydm"].
|
|
32
|
|
|
33
|
/* List of date variable formats to test */
|
|
34
|
DEFINE VARIABLE varFormats AS CHARACTER NO-UNDO EXTENT 576
|
|
35
|
INITIAL [ {all-date-formats.i} ].
|
|
36
|
|
|
37
|
/* Loop variables */
|
|
38
|
DEFINE VARIABLE i AS INTEGER NO-UNDO.
|
|
39
|
DEFINE VARIABLE j AS INTEGER NO-UNDO.
|
|
40
|
|
|
41
|
/* Iterate over SESSION:DATE-FORMAT values */
|
|
42
|
DO i = 1 TO EXTENT(dateFormats):
|
|
43
|
/* Set SESSION:DATE-FORMAT */
|
|
44
|
SESSION:DATE-FORMAT = dateFormats[i].
|
|
45
|
|
|
46
|
/* Redirect output to a file */
|
|
47
|
OUTPUT TO VALUE( "date_format_assignment_adjusted_" + dateFormats[i] + ".i" ).
|
|
48
|
|
|
49
|
/* Iterate over variable formats */
|
|
50
|
REPEAT j = 1 TO EXTENT(varFormats):
|
|
51
|
/* Apply the format to the date variable within the frame */
|
|
52
|
d:FORMAT IN FRAME myFrame = varFormats[j].
|
|
53
|
|
|
54
|
/* Print the format just set and the FORMAT attribute with newline */
|
|
55
|
PUT UNFORMATTED '"' + ( d:FORMAT IN FRAME myFrame ) + '",~n'.
|
|
56
|
// DISPLAY
|
|
57
|
// '"' + ( d:FORMAT IN FRAME myFrame ) + '",' FORMAT "x(20)"
|
|
58
|
// .
|
|
59
|
END.
|
|
60
|
|
|
61
|
OUTPUT CLOSE.
|
|
62
|
END.
|