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: DIALOG issues  (Read 12257 times)
Snorri B.
Posts: 103


« on: January 03, 2019, 06:46:06 pm »

Hi.

Assume you have an INPUT statement

Code
  1. INPUT BY NAME ...
  2. ....
  3.  ON ACTION CANCEL EXIT INPUT
  4. END INPUT
  5.  

If the user presses cancel the Input statement is exits immediately without any any field validation. So the user can input any garbage into a field (like 1234 in a DATE) and then press cancel without getting the "Error in field" message. This behavior is different in DIALOG however. If you put the code above in a dialog:
Code
  1. DIALOG ATTRIBUTES (UNBUFFERED)
  2.   INPUT BY NAME ...
  3.    ....
  4.     ON ACTION CANCEL EXIT DIALOG
  5.  END INPUT
  6.  
  7.  ON ACTION CANCEL EXIT DIALOG
  8. END DIALOG
  9.  

In this case, the current field is validated and the user gets the "Error in field" error message. So the user has to clear the contents of the field before exiting. (This also applies to SUBDIALOGs)

Is this the intended behavior?

Thanks,
-Snorri
Daniel N.
Posts: 6


« Reply #1 on: January 03, 2019, 08:05:14 pm »

Hi

in DIALOG it depends on the "validate" attribute.

Please have a look at:
https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_prog_dialogs_action_validate.html

Best regards
Andrea
Snorri B.
Posts: 103


« Reply #2 on: January 03, 2019, 09:02:26 pm »

Thanks Andrea.

Best regards,
-Snorri
Reuben B.
Four Js
Posts: 1049


« Reply #3 on: January 03, 2019, 09:11:30 pm »

It is not really an INPUT versus DIALOG issue, it is buffered versus unbuffered.  With unbuffered the value entered is placed into the target variable and thus the checks occur that the value can be entered into the target variable

As well as the link Andrea gave you, have a look at explanation of buffered vs unbuffered
https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_prog_dialogs_unbuffered.html

and I also like this link https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_action_attribute_VALIDATE.html as it emphasises different ways of setting the attribute.  I'd expect you'd typically set validate="no" for actions with names such as cancel, help, zoom, wizard, delete, close, dialogtouched in your global .4ad.  You can see this in FGLDIR/lib/default.4ad

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Snorri B.
Posts: 103


« Reply #4 on: January 04, 2019, 12:22:02 pm »

In my testing, a standalone INPUT BY NAME ATTRIBUTE(UNBUFFERD), will NOT check the variables, it exits immediately.
If you just put this into DIALOG, it will.

Regards,
-Snorri
Rene S.
Four Js
Posts: 111


« Reply #5 on: January 04, 2019, 01:53:24 pm »

Hi Snorri,
Andrea is right: your problem belongs to the validate attribute of the ACTION cancel.
Inspect the action-defaults:

Code
  1. <ActionDefault name="cancel" validate="no" text="Cancel" acceleratorName="Escape" contextMenu="no"/>

Why does not ON ACTION cancel validate the current field in a standalone INPUT? Any standalone INPUT has a builtin cancel action. This action never validates the current field. A user defined ON ACTION cancel inherits this behavior. ON ACTION cancel behaves like ON KEY INTERRUPT in the old TUI days.

Why does ON ACTION cancel might validate the current field in a DIALOG? A DIAOLG has no builtin actins. An ACTION cancel haves like any other ACTION: the attribute VALIDATE controls if or if not the current field must be validated before executing the actions code.
 
BTW: (minor, side remark)
Don't code like
Code:
ON ACTION CANCEL EXIT DIALOG
Replace ON ACTION CANCEL by ON ACTION cancel, replace EXIT DIALOG by CANCEL DIALOG.
Code:
ON ACTION cancel CANCEL DIALOG
cancel is not a keyword here. The compiler simply reads: "ON ACTION action-name" where action-name is a simple identifier.
Avoid EXIT DIALOG, use CANCEL DIALOG. CANCEL DIALOG performs the same cleanup as the builtin cancel action of standalone inputs does.

Rene


Snorri B.
Posts: 103


« Reply #6 on: January 04, 2019, 02:59:13 pm »

Thanks Rene.

This CANCEL DIALOG is new to me. There almost no mention of it in the docs (only in dialog.cancel()) I'ts not listed as one of the dialog commands.
https://4js.com/techdocs/fjs-fgl-manual/#fgl-topics/c_fgl_ui_syntax_proc_DIALOG.html

Excerpt:

where dialog-statement is one of:
{ statement
| ACCEPT DIALOG
| CONTINUE DIALOG
| EXIT DIALOG
| NEXT FIELD
   { CURRENT
   | NEXT
   | PREVIOUS
   | field-spec
   }
}
Sebastien F.
Four Js
Posts: 509


« Reply #7 on: January 04, 2019, 03:42:41 pm »

This is a certainly a documentation bug.
We need to clarify what is the difference between EXIT DIALOG and CANCEL DIALOG.
Note there is no CANCEL INPUT for singular INPUTs, only ACCEPT INPUT and EXIT INPUT.
Seb
Richard H.
Posts: 9


« Reply #8 on: January 07, 2019, 10:21:39 am »

BTW: (minor, side remark)
Don't code like
Code:
ON ACTION CANCEL EXIT DIALOG
Replace ON ACTION CANCEL by ON ACTION cancel, replace EXIT DIALOG by CANCEL DIALOG.
Code:
ON ACTION cancel CANCEL DIALOG
cancel is not a keyword here. The compiler simply reads: "ON ACTION action-name" where action-name is a simple identifier.

The Genero Studio default preference for "Automatically convert all keywords to upper case" is set to TRUE.  Because of this Genero Studio sees the word 'cancel' as a keyword even if it is used where an action name is expected and capitalises it.

Your comment, Rene, would seem to indicate that there is a bug with the syntax checker in Genero Studio.

I am using Genero Studio version 3.10.10 build-161228.

Regards,
Richard.
Rene S.
Four Js
Posts: 111


« Reply #9 on: January 07, 2019, 11:37:56 am »

I don't know how Studio detect keywords.
Yes, Studio should not automatically shift the case of keywords used as identifiers.

About the case "ON ACTION cancel": Simply try the auto-completion. o<tab> completes to ON, ON a<tab> completes to ON ACTION, ON ACTION c<tab> proposes nothing.

Rene
Reuben B.
Four Js
Posts: 1049


« Reply #10 on: January 07, 2019, 11:56:56 am »

Richard,

The issue you raise with Studio happens with ALL keywords.

Try typing

Code
  1. DEFINE form, begin, end, to DATE

and
Code
  1. MENU ""
  2.   ON ACTION insert
  3.   ON ACTION update
  4.   ON ACTION delete
  5. END MENU

and note that from, begin, to, end, update, delete, insert are all uppercased.  In simplistic terms if you have the preference enabled, as you finish typing a word ie a space, Studio is looking to see if the word is in a list of keywords, if it is upper case it.  There is a little bit of logic as it can detect if you are in the middle of a string and not upper case, but not a great deal of logic.

If you are participating in the Genero 3.20 EAP which is on now, you will see that there is a new code beautifier, and that is clever enough to detect keywords when they are used as keywords and upper case them appropriately.  Interestingly that code has to compile cleanly in order for the code beautifier to do its thing.  So if you have not already, please sign up for the EAP https://4js.com/download/eap/ and provide feedback on the code beautifier and other new features.

Reuben






Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Richard H.
Posts: 9


« Reply #11 on: January 07, 2019, 12:01:18 pm »

Thanks Reuben, sounds good.  I look forward to seeing it in action.
Rene S.
Four Js
Posts: 111


« Reply #12 on: January 07, 2019, 12:10:34 pm »

To avoid wrong expectations:
Yes, the formatter upshifts keywords (since 3.20.01: downshifts keyword optionally)
But: the formatter can not change "ON ACTION CANCEL" to "ON ACTION cancel". The formatters reads the identifier "CANCEL" and does not touch the case. BTW: this could eventually be the subject of a new compiler warning: don't use uppercase identifiers being keywords in another context.
Rene
Richard H.
Posts: 9


« Reply #13 on: January 07, 2019, 12:19:54 pm »

I would typically type:

on action cancel cancel input

and leave the capitalisation to the formatter.  The result is this:

ON ACTION CANCEL CANCEL INPUT

Be aware that users of Genero Studio may suddenly be seeing hundreds of compiler warnings where this sort of thing has happened and will probably choose to ignore the compiler warning in preferences rather than go and fix the errors (and potentially have to fight the formatter to stop it re-capitalising the word).
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines