7. Adding your own Code with POINTs

Genero Studio video scripts

Related video: 7. Adding your own Code with POINTs

Though the Business Application Modeler generates the code for your application, you can still add your own code to customize the application as you see fit.


Introducing POINTs and BLOCKs

There are special areas of the generated 4gl files called POINTs and BLOCKs for you to add your own code. The code you add to POINT and BLOCK sections are preserved even with the application is regenerated as it is kept in a special .code file that is used in the building process.

First, it is important to understand that 4gl files are generated for each implemented component on your BA diagram and listed in the Intermediate Files. For a form component, you will see a form_ui.4gl and form_uidata.4gl, where form is the name of your form component.

Form_ui.4gl and Form_uidata.4gl are compiled and linked with the other program files to create the executable application. These are the files where you find the POINT and BLOCK sections.

Form_ui.4gl includes the MAIN and loads resource files and does some preliminary setup including launching the functions containing the Menu or Dialog statements for the various states. It also imports and calls functions in the other generated file, Form_uidata.4gl.

Form_uidata.4gl defines records and handles the create, retrieve, update, and delete data routines (CRUD).

Now consider two examples of using a POINT section to add code. In Video 8, you can see an example of using a BLOCK section.

In the first example, you will see how to modify the SELECT statement so that the application only retrieves account records from the USA.

In the second example, you will see how to add your own action to the program and have that action call your own function.


POINT Example one – Modify the select

  1. To start, open the file to which you want to add code.
  2. Now, search for the POINT section that follows the select statement you want to modify. Note that the POINT section has a name at approximately line 258.
  3. Between the POINT and end POINT tags, add your new select statement with the where clause modified.
  4. Now recompile and run the program. The program now retrieves only USA accounts.
  5. Now, take a look at the uidata.4gl file again. Note that there is a status value that has now been set to MODIFIED, indicating that this POINT has been altered. Also, behind the scenes, the Form_uidata.code file has been updated with your POINT code.


POINT Example two – Add a new action and function

For this example, you will see how to add code to two POINT sections in the Form1_ui.4gl file. You will create a new action that is available when the user modifies the form. When the action is triggered, a message will appear.

  1. First, find the interactive dialog where you want your action to be available. Since you want the action available when the user is modifying the form, look for the INPUT dialog. Each interactive dialog statement has an addControlBlocks POINT. Here you see “fct.uiInput.dialog.addControlBlocks”, so add your ON ACTION code here.
  2. Now, at the very bottom of the 4gl file, there is a POINT for user functions. Add your function here.
  3. Now, regenerate the program and run it to see your new action.
  4. Note that when you go into an INPUT mode, (modify button), your new action appears as a button on the form. Select the button to see your message.
  5. You can move this action to the toolbar or top menu area instead of its default position on the form. See Video #5 on Modifying the TopMenu and ToolBar to do