-->
software
software
software
In this lesson we are going to learn how to use the different attributes of A4gl like:
“Checkboxes” , “Combobox” , “Dateedit” and “Textedit”.

Attributes

Now we create a new file named m_attributes.per

DATABASE FORMONLY

SCREEN
{
Juice Voting!
————————————————————————————-
Do you like Apple Juice?      Yes [mx1 ]   No [mx2 ]
————————————————————————————–
When not choose one             [mx3 ] [mx9 ]
————————————————————————————–
Which date do you like it?       [mx4 ]
————————————————————————————–
From State [mx6 ] [mx7 ]
————————————————————————————–
Other answers [mx5      ]
[mx5      ]
}

ATTRIBUTES

CHECKBOX mx1 = FORMONLY.mx1, COLOR=RED, REQUIRED, TEXT=”Yes”;
CHECKBOX mx2 = FORMONLY.mx2, COLOR=BLUE, REQUIRED, TEXT=”No”;

COMBOBOX mx3 = FORMONLY.ecombo, ITEMS=(”Banana Juice”,”Tomato Juice”);
COMBOBOX mx9 = FORMONLY.color TYPE CHAR;
DateEdit mx4 = FORMONLY.edate;
TextEdit mx5 = FORMONLY.etext, UPSHIFT, VALUEMAX=40, STYLE=”normal” WANTTABS;
BUTTONEDIT mx6 = FORMONLY.button, IMAGE=”f5″, ACTION=f5;
BUTTONEDIT mx7 = FORMONLY.buttonhide, INVISIBLE;
EDIT mx8 = FORMONLY.number, UNHIDABLE, INCLUDE=(0,1,2,3);

With DateEdit you can select a date through the integrated calendar, with “TextEdit” you can write a long text, “ComboBox” is for the pulldown that allows you to choose an option and with the “CHECKBOX” you can select the options with a click. In this example, you can see the different characteristic of the different attributes.

Now we create our main file named “m_attributes.4gl”

MAIN

   DEFINE edate CHAR(255),
                   etext CHAR(255),
                   ecombo CHAR(255),
                   number INTEGER,
                   button CHAR(255),
                   string STRING

   CLOSE WINDOW screen

   CALL ui.Interface.loadActionDefaults(”default”)
   CALL ui.Interface.loadStyles(”default”)

   OPEN WINDOW attributes WITH FORM “m_attributes”

   MENU “Navigation”
      COMMAND “Ok”
         IF string IS NULL
            THEN LET string = “Please fill the Fields”
         END IF
         CALL auswert(string)
      COMMAND “Edit”
         CALL edit_date() RETURNING string
      COMMAND “Cancel”
         EXIT MENU
   END MENU

END MAIN

FUNCTION edit_date()
   DEFINE edate CHAR(255),
                   etext CHAR(255),
                   number INTEGER,
                   ecombo CHAR(255),
                   cb ui.Combobox,
                   color CHAR(3),
                   button CHAR(255),
                   string STRING

   LET cb = ui.ComboBox.forName(color”)
   CALL cb.clear()
   CALL cb.addItem (”Yellow”, “Yellow Banana Juice”)
   CALL cb.addItem(”Red”, “Red Tomato Juice”)
   CALL cb.addItem(”Red”, “Red Apple Juice”)
   CALL cb.addItem(”Yellow”, “Yellow Apple Juice”)

   OPTIONS INPUT WRAP

   INPUT BY NAME edate,
                                  etext,
                                  number,
                                  ecombo,
                                  button

   BEFORE INPUT
      DISPLAY “00-00-0000″ TO edate

   AFTER FIELD edate
      IF edate IS NULL
         THEN LET edate = TODAY
      END IF

   END INPUT

LET string = “Your Date: “, edate CLIPPED, “\n”,
                       ”Your choose: “, ecombo CLIPPED, ” Color: “, color CLIPPED, “\n”,
                        ”Number: “, number CLIPPED, “\n”,
                        ”Other answers: “, etext CLIPPED, “\n”

RETURN string
END FUNCTION

FUNCTION auswert(string)
   DEFINE string STRING

   MENU “Your Voting result:”
   ATTRIBUTE (STYLE =”dialog”,
                           COMMENT = string CLIPPED)
      COMMAND “Ok”
         EXIT MENU
         RUN “fglgo attributes.4ae”
   END MENU
END FUNCTION

Now you can compile this example with “4glpc m_attributes.4gl -o attributes.4ae” and see the result:

Attributes