8. Adding your own Code with BLOCKs

Genero Studio video scripts

Related video: 8. Adding your own Code with BLOCKs

BLOCK Example one – Display a Message Window

Each function in the generated code is nested within a BLOCK section. This means that you can change the behavior of the generated function.  However, once you add new code to a BLOCK, you take responsibility for the validity of all the code in that BLOCK.

First, identify the modification to be made. Currently in the Office Store example application, if the user modifies the quantity of a line item, he is prompted to accept or cancel his change. Modify this so that if he does confirm the change of the quantity of the line item, a new message displays with the new total.

Next, identify where in the code you will add your own code. In the OrderForm_ui.4gl is a function called FUNCTION OrderForm_uiInput(). Within that function is an INPUT ARRAY m_OrderItem FROM OrderItem.*… Here you can see that the AFTER ROW block is where the first confirmation message displays. This the right place to add the new code. The new message will pop up only when the user confirms their change (C_YES).

— custom code begin        

       CALL FGL_WINMESSAGE( “New Total”,

       SFMT(“New Total for this Item: %1”,

       m_OrderItem[DIALOG.getCurrentRow(“orderitem”)].lineitem_quantity *



— custom code end

Compile and run to see the change.