Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Change INPUT ARRAY attribute  (Read 11734 times)
David Z.
Posts: 19


« on: May 14, 2012, 11:13:28 pm »

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.
Four Js
Posts: 1113


« Reply #1 on: May 14, 2012, 11:56:42 pm »

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
  1. DEFINE insert_allowed BOOLEAN
  2. ...
  3.    LET insert_allowed = TRUE
  4.    INPUT ARRAY arr FROM scr.*  ATTRIBUTES(INSERT ROW=insert_allowed)
  5.        ON ACTION toggle
  6.            LET insert_allowed = NOT insert_allowed
  7.            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.
Posts: 19


« Reply #2 on: May 15, 2012, 03:33:38 pm »

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
  1. input array progarrayname without defaults from screenarrayname
  2.   attribute (insert row = false)
  3.   on action toggle
  4.      dialog.setActionActive("insert", TRUE)

I will get error -8089. But this works:

Code
  1. input array progarrayname without defaults from screenarrayname
  2.   attribute (insert row = true)
  3.   on action toggle
  4.      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.
Four Js
Posts: 1113


« Reply #3 on: May 15, 2012, 10:31:01 pm »

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
  1.    LET insert_allowed = FALSE
  2.    INPUT ARRAY arr FROM scr.*  
  3.        BEFORE INPUT
  4.            CALL DIALOG.setActionActive("insert", insert_allowed)
  5.        ON ACTION toggle
  6.            LET insert_allowed = NOT insert_allowed
  7.            CALL DIALOG.setActionActive("insert", insert_allowed)
  8.    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.
Four Js
Posts: 112


« Reply #4 on: May 16, 2012, 08:32:56 am »

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.
Posts: 19


« Reply #5 on: May 16, 2012, 03:25:51 pm »

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
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines