We start by making a new file called “m_date.per” to build our screen form:
DATABASE FORMONLY SCREEN { [mx1 ] [date ] [date1 ] [date2 ] [date3 ] } ATTRIBUTES LABEL mx1 = FORMONLY.text_dateedit; DateEdit date = FORMONLY.dateedit TYPE DATE, REQUIRED, NOT NULL, COLOR=BLUE, FORMAT=”yyyy/mm/dd”; DateEdit date1 = FORMONLY.dateedit1, NOENTRY, NOT NULL; DateEdit date2 = FORMONLY.dateedit2, NOENTRY, DEFAULT=”01.09.1990″; DateEdit date3 = FORMONLY.dateedit3, HIDDEN;
Compile the screen form with “fcompile -xml m_date.per” and start writing our simple example program “m_date.4gl” for the test:
MAIN DEFINE text_dateedit CHAR(50) DEFINE dateedit DATE CLOSE WINDOW screen CALL ui.Interface.loadActionDefaults(”default”) CALL ui.Interface.loadStyles(”default”) OPEN WINDOW w_1 WITH FORM “m_date” CALL ui.Interface.settext(”DateEdit Example”) LET text_dateedit = “Dateedit: ” DISPLAY BY NAME text_dateedit, dateedit ATTRIBUTES(RED) MENU “Navigation” COMMAND “Edit” CALL init_date() COMMAND “Exit” EXIT MENU END MENU END MAIN FUNCTION init_date() DEFINE dateedit DATE DEFINE dateedit1 DATE DEFINE dateedit2 DATE OPTIONS INPUT WRAP INPUT BY NAME dateedit dateedit1, dateedit2 END FUNCTION
Compile this example with “4glpc m_date.4gl -o date.4ae”
Our Enviroment variable “DBDATE” has the FORMAT: “DMY4.”.
TheD = Day M = Month Y4 = Year and the point at the end of the line is our seperator like: “13.03.1988″.
Our screen form will now look like this:
In the next Step, we are going to change the FORMAT to:
DateEdit date = FORMONLY.dateedit TYPE DATE, FORMAT=”yyyy/mm/dd”;
If you want to see the correct FORMAT you must change the enviroment variable to: “export DBDATE=Y4MD/”
If you want to see the current eviroment variable use: “echo $DBDATE” in the terminal. We have now changed the enviroment variable and the screen form. If you want to see the following result then recompile the .per file withh “fcompile -xml m_date.per” and run the program again.
Now we have finished to change the DateEdit format