Was this helpful?
The 4GL Code for NewOrder
The QUEL version of the 4GL code for NewOrder is shown below. This code declares a menu with three operations: Add, Find, ListChoices and End. The first two operations contain examples of query statements (append and retrieve). ListChoices uses the built-in procedure help_field().
initialize (cnum = integer, 
    rcount = smallint) = 
begin
end

"Add" = 
begin
    if custnum = 0 then
        message "You must enter a customer" +
            " number before selecting ADD";
        sleep 2;
        resume;
    endif;
    append to orders (product = product, 
        custname = custname, custnum = custnum, 
        quantity = quantity, currentdate = "today");
    append to marketing (prod = product, 
        quantity = quantity);
    /* Check if a record exists in the table     */
    /* customer having the customer number in    */
    /* field "custnum" */
    neworder = retrieve (cnum = customer.number)
        where customer.number = custnum;
    /* See if a record already exists */
    inquire_ingres(rcount = rowcount)
    if rcount = 0 then
        append to customer (name = custname,
            number = custnum,
            address = "Whereabouts unknown");
    endif;
end
"Find" = 
begin
    if custnum = 0 then
        message "You must enter a customer" +
            " number before selecting FIND";
        sleep 2;
        resume;
    endif;
    /* Write the customer name into the    */
    /* "custname" field for the customer */
    /* number specified in the field "custnum"*/
    neworder = retrieve (customer.name)
        where customer.number = custnum;
    /* See if a row was found for that     */
    /* customer number */
    inquire_ingres(rcount = rowcount);
    if rcount = 0 then
         message "No such customer number";
        sleep 2;
        resume;
    endif;
    clear field product, quantity;
end
/* ListChoices for field.  For the product     */
/* field this displays possible products,        */ 
/* taken from the Validation Check to        */ 
/* Perform field in the VIFRED Creating a        */
/* Form frame */
"ListChoices" = 
begin
    callproc help_field(); 
        /*Built-in procedure */
end

"End", key frskey3 = 
begin
    return;
end
Last modified date: 11/09/2022