Change INPUT ARRAY attribute

Started by David Z., May 14, 2012, 11:13:28 PM

Previous topic - Next topic

David Z.

FGL = 2.32.03

If I have something like:

input array progarrayname without defaults from screenarrayname
   attribute (insert row = false)
......
......
end input

How can I set "insert row = true" within the input array statement? I need to toggle "insert row" on and off while the user is in the insert array statement.

Thanks
David

Reuben B.

Use the setActionActive method of the DIALOG class https://4js.com/online_documentation/fjs-fgl-manual-html/User/ClassDialog.html#setActionActive

remembering that INPUT ARRAY has these built-in actions https://4js.com/online_documentation/fjs-fgl-manual-html/User/InputArray.html#DEFAULT_ACTIONS

Experiment with something like ...

Code (genero) Select
DEFINE insert_allowed BOOLEAN
...
    LET insert_allowed = TRUE
    INPUT ARRAY arr FROM scr.*  ATTRIBUTES(INSERT ROW=insert_allowed)
        ON ACTION toggle
            LET insert_allowed = NOT insert_allowed
            CALL DIALOG.setActionActive("insert", insert_allowed)
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero

David Z.

Reuben,

I thought about setActionActive() but dialog.setActionActive("insert", TRUE) gives a runtime error -8089 Action "insert" not found in dialog. I get the same error for "insert row". I did find a solution. If I start the INPUT ARRAY this way:

Code (genero) Select
input array progarrayname without defaults from screenarrayname
   attribute (insert row = false)
   on action toggle
      dialog.setActionActive("insert", TRUE)


I will get error -8089. But this works:

Code (genero) Select
input array progarrayname without defaults from screenarrayname
   attribute (insert row = true)
   on action toggle
      dialog.setActionActive("insert", FALSE)


In other words, INSERT ROW must be TRUE in the INPUT ARRAY ATTRIBUTE for setActionActive() to see it elsewhere in the INPUT ARRAY. Is this expected behavior or a bug in Genero?

David


Reuben B.

Hi David,

The developers will have to confirm if that is deliberate but I suspect it is.  The ATTRIBUTES clause determines if the action is added to the dialog to begin with.  Using the setActionActive method we are only changing the value of the active attribute of the action. 

I would actually tend to use this pattern as the same technique can be applied to all actions in the dialog.

Code (genero) Select
    LET insert_allowed = FALSE
    INPUT ARRAY arr FROM scr.* 
        BEFORE INPUT
            CALL DIALOG.setActionActive("insert", insert_allowed)
        ON ACTION toggle
            LET insert_allowed = NOT insert_allowed
            CALL DIALOG.setActionActive("insert", insert_allowed)
    END INPUT


Reuben

PS Do you know Control-RightClick when GDC is started in debug mode (-D) to view the DOM tree? If you look at that, you will see the action nodes belonging to the dialog and their attribute values.
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero

Rene S.

Hello,
yes Reuben's explanation is correct: the attribute INSERT ROW = FALSE prohibits the creation of the built-in insert action. If the action has not been created, a runtime error is legal and expected when accessing this not existing action with the method DIALOG.setActionActive().
Rene

David Z.

Reuben,

My program does use variables like you are using (input_allowed). My TRUE and FALSE were for demonstration purposes. Rene says it is expected behavior. That is fine. Its not hard to program around it. It didn't occur to me that INSERT had to be TRUE in the INPUT ARRAY ATTRIBUTE clause for setActionActive() to see it. Is this in the documentation? I didn't see it.

David