-->
software
software
software
In this lesson we are going to create a construct for revive a string to make a sql statement.

A4GL Construct

We start by making our construct.per file:

DATABASE FORMONLY

SCREEN
{
   First Name: [mx1 ]
   Last Name: [mx2 ]
   E-Mail: [mx3 ]
}

ATTRIBUTES
mx1 = FORMONLY.fname;
mx2 = FORMONLY.lname;
mx3 = FORMONLY.mail;

We also compile this .per file with “fcompile -xml construct.per” and create a new file “construct.4gl” to make our window.

MAIN

   DEFINE string STRING,
                   fname CHAR(50),
                   lname CHAR(50),
                   mail CHAR(255)

   CLOSE WINDOW screen

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

   OPEN WINDOW construct WITH FORM “m_construct”

   OPTIONS INPUT WRAP

   CONSTRUCT string
      ON fname,
             lname,
             mail
      FROM fname,
                  lname,
                  mail

   BEFORE CONSTRUCT
      DISPLAY “Your Name” TO fname
      DISPLAY “Your last Name” TO lname
      DISPLAY “Your E-Mail” TO mail

   BEFORE FIELD fname
   AFTER FIELD fname
      MESSAGE “AFTER FIELD fname”

   BEFORE FIELD lname
   AFTER FIELD lname
      MESSAGE “AFTER FIELD lname”

   BEFORE FIELD mail
   AFTER FIELD mail
      MESSAGE “AFTER FIELD mail”

      AFTER CONSTRUCT
      DISPLAY “AFTER CONSTRUCT”
      ON KEY (ESC)
         RETURN 0

      END CONSTRUCT

      CALL cdialog(string)

END MAIN

FUNCTION cdialog(string)
   DEFINE string STRING
   LET string = “CONSTRUCT STRING:\n\n”, string CLIPPED

   MENU “CONSTRUCT DIALOG”
      ATTRIBUTE (STYLE = “dialog”,
      COMMENT = string CLIPPED)

   COMMAND “Ok”
      EXIT MENU
         RUN “fglgo construct.4ae”
   END MENU
END FUNCTION

“CONSTRUCT … ON … “ creates a string from our form fields.
“BEFORE CONSTRUCT”
creates in our examples the input fields.
“AFTER FIELD …”
displays a message in the messageline after each row.
“END CONSTRUCT”
calls our function cdialog to display the string in a new window and with
“RUN fglgo … “
you can load the program again or another one.

With cdialog() we display the “string” which has created the construct into our dialogbox.

A4GL Construct Example

You have now finished the “CONSTRUCT” example.
If you compile this program with “4glpc construct.4gl -o construct.4ae” you can see the result:

A4GL Construct Example