Previous Topic: Creating a Function to Work with Projects and Tasks

Next Topic: Modifying the Panel

Adding Action Diagram Code

Now that you have created the function, you need to add a bit of code so that the project parts can interact with the task parts. You will be adding code to:

To modify Project.Maintain Projects:

  1. Open the action diagram for Project.Maintain Projects.

    The patterns in UIBASIC are more primitive than the patterns in FOUNDATION. They do not make any assumptions about how you want to use them. The patterns in FOUNDATION are intended to be ready to use with just a generate and build. So, when you use patterns from the UIBASIC Pattern Library, you have to add some initialization and setup code to the part of the function that inherits from Grid2. If you do not do this, projects will not appear on the list until you click the Refresh button.

  2. Click Cancel in the Select Edit Point dialog.
  3. Enter End Initialize in the input line, and press F4.

    The following processing is added in the End Initialize Post Point because the grid should be loaded after the rest of the panel is initialized, but before it is displayed.

  4. Double-click the Post Point below the End Initialize Edit Point.

    This is the first Post Point that already has content:

    Adding Action Diagram Code

    You can only add code at the end of a Pre or Post Point, below any statements that are already there.

  5. Click just below the Go Sub Reload Grid line, and enter the following statement:
    Go Sub Reload Grid2
    

    This statement loads the project grid when the panel is initialized.

  6. In the Variable Palette, expand the Local variable group.
  7. Drag the Project ID field from the Object Browser to Position Grid2.
  8. Navigate to the End Initialize Grid2 Post Point.
  9. Inside the End Initialize Grid2 Post Point, enter the following statement:
    Set PositionGrid2<Project ID> = <Project ID.*Blank>
    

    Note: You can find the PositionGrid2 variable in the Local variable group.

    This statement tells the function to read the database starting with the first project. If you did not add this statement, the function that reloads the grid would start wherever it stopped the last time it read projects.

  10. In the Variable Palette, expand the Local variable group.
  11. Drag the Project ID field from the Object Browser to the Restrict variable.
  12. Navigate to the Post Point below the Process Selected Grid2 Row Edit Point.
  13. Enter the following statements:
    Set Restrict = Grid2P
    Go Sub Reload Grid
    

    This sets the values of the fields in Restrict variable equal to the corresponding fields in the currently selected row in the project grid. This means that you only get a list of the tasks for that project from the database, and then it reloads the project grid. Remember, when the function loads the task grid, it uses the BlockFetchSet function, which checks the Restrict variable to determine which tasks to load.

  14. Navigate to the Post Point below the End Reload Grid2 Edit Point.
  15. Enter the following statement:
    For Each Selected Grid2P
    
  16. Enter the following statements inside the new construct:
    Set Restrict = Grid2P
    Go Sub Reload Grid
    

    These statements display the tasks associated with any selected projects in the Grid2P region.

  17. To check that you entered all the required code, choose Show Local Modifications from the View menu. Use the space bar to expand each construct.

    Your action diagram should look like the following example. This example includes extra comments in the code:

    PLEX--Adding Action Diagram Code (2)

  18. Reset the action diagram display by choosing Show Full Logic from the View menu.
  19. Save your model and close the action diagram.