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: Compile help  (Read 8266 times)
Huy H.
Posts: 45


« on: December 12, 2019, 11:32:32 pm »

What am I doing wrong here? It seems I cannot compile when an ACTION follows by both INFIELD and ATTRIBUTES.

Code
  1.  INPUT BY NAME discount
  2.    ON ACTION prefill { compiles ok }
  3. --  ON ACTION prefill INFIELD discount { compiles ok }
  4. --  ON ACTION prefill ATTRIBUTES(DEFAULTVIEW=YES) { compiles ok }
  5. --  ON ACTION prefill INFIELD discount ATTRIBUTES(DEFAULTVIEW=YES) { ERROR }
  6. --  ON ACTION prefill ATTRIBUTES(DEFAULTVIEW=YES) INFIELD discount { ERROR }
  7.      LET discount = 10
  8.    ON ACTION accept
  9.      ACCEPT INPUT
  10.    ON ACTION cancel
  11.      EXIT INPUT
  12.  END INPUT

http://genero.versaterm.com/BDL/3.20/#fgl-topics/c_fgl_dialog_ON_ACTION.html
Rene S.
Four Js
Posts: 111


« Reply #1 on: December 13, 2019, 09:19:17 am »

Hello, this is a compiler bug/weakness.
When introducing ON ACTION action-name ATTRIBUTES() we excluded  ON ACTION action-name iNFIELD field-name ATTRIBUTES(). Why? The semantics was not clear. What happens in this example:
Code
  1. ON ACTION foo INFIELD field1 ATTRIBUTE(DEFAULTVIEW = YES, TEXT = "abc", ACCELERATOR = "Control-X")
  2. ON ACTION foo INFIELD field2 -- without attributes
What happens if the focus switches from field1 to field2? The answer should be: DEFAULTVIEW = auto, TEXT = "foo", no accelerator.

In 3.00.05 we have fixed: https://agile.strasbourg.4js.com/jira/browse/FGL-4140 ON ACTION ATTRIBUTES must belong to the sub-dialog.
That's a similar situation:
Code
  1. DIALOG
  2.    INPUT ..
  3.        ON ACTION foo ATTRIBUTE ...
  4.    INPUT ..
  5.        ON ACTION foo ATTRIBUTE ...
  6. END DIALOG

I've created this new bug:
https://agile.strasbourg.4js.com/jira/browse/FGL-5311 ui: ON ACTION ATTRIBUTES should be possible for actions with INFIELD clause.
Out of scope:
My instinct: the same action should have in any context the same attributes. It's kind of annoying to repeat the attributes when using an action more than once. For that reason: use action defaults, avoid action attributes in the 4GL code.
Use the ATTRIBUTES clause only for actions appearing no where else in your project.



Rene S.
Four Js
Posts: 111


« Reply #2 on: December 13, 2019, 09:29:35 am »

I've overseen this existing bug:
https://agile.strasbourg.4js.com/jira/browse/FGL-4542 ON ACTION .. INFIELD does not allow ATTRIBUTE(S)
Anyway, don't expect any activity on this issue. There is no added value compared to regular action defaults - except your are really excepting different attributes in different contexts.

Reuben B.
Four Js
Posts: 1048


« Reply #3 on: December 17, 2019, 04:43:47 am »

Rene,

Did you consider the case of a one-off action where it is preferred to define all you need to with the ON ACTION, and therefore no need to touch a .4ad or .per.  In that case I think ...


Code
  1. ON ACTION foo INFIELD field1 ATTRIBUTES(TEXT="...", IMAGE="...")
  2.  
would be preferred to


Code
  1. BEFORE INPUT
  2.    CALL DIALOG.setActionActive("foo", FALSE)
  3. BEFORE FIELD field1
  4.    CALL DIALOG.setActionActive("foo", TRUE)
  5. AFTER FIELD field1
  6.    CALL DIALOG.setActionActive("foo", FALSE)
  7.  
  8. ON ACTION foo ATTRIBUTES(TEXT="...", IMAGE="...")

Reuben

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: 111


« Reply #4 on: December 17, 2019, 08:29:34 am »

Hello Reuben,
Yes, I did.
OTH: why adding extra code (setActionActive here and there) if on action infield exists? On action infield has been introduced for exactly this reason: simplify the 4gl code. The runtime controls the activation of actions.

If (hypothetically) the attribute clause would be supported for an on action infield then we end in the dilemma: the programmer must repeat all attributes for each action with the same name. This is the opposite of simple.
Huy H.
Posts: 45


« Reply #5 on: December 17, 2019, 03:27:52 pm »

For us, this is sort of a one-of situation.  We have our action defaults defined in a 4ad file.  In this particular situation, we wanted the attributes of this action to be different than the defaults defined within the 4ad.  We've used INFIELD and ATTRIBUTES in the past, it just wasn't clear to us that the two cannot be used together in the code.  It's not a big deal really, we've found a work around that we think it's more intuitive to the user:  We added a button on the form next to the field (therefore DEFAULTVIEW = YES) and only used the INFIELD in the code.

Like Rene had alluded to, there's other ways that we can do to get to the behavior we desire, just that it wasn't obvious to us why the syntax didn't work.
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines