Form and Windows names/identifiers

Started by Luís T., October 25, 2017, 01:04:19 PM

Previous topic - Next topic

Luís T.

As far I understand windows and form identifiers must be unique in the scope of the program:
"The form identifier does not need to match the name of the form specification files, but it must be unique
among form names in the program. Its scope of reference is the entire program."


Suppose I have a CRUD in clients and, while inputting an client, I need to call that same CRUD to get another client (for instance the partner).

This will be solvable if the window/form identifier is local to the function.

Has anybody already faced this issue? What will be the solution for that?

PS: I think the same reasoning can be applied to cursors, which I think are also global identifiers.

Reuben B.

A few potential solutions...

QuoteSuppose I have a CRUD in clients and, while inputting an client, I need to call that same CRUD to get another client (for instance the partner).
Lets say your program is called client_crud.  You could write your program in such a way that you can go recursively call that same program from your program and go straight to a particular part of the program e.g....

Code (genero) Select
ON ACTION view_partner
    LET cmd = "fglrun client_crud --mode=read --id=", l_partner_id
    RUN cmd


... as it is a seperate instance of the program, you avoid the issue with window/form identifiers.


Code (genero) Select
Has anybody already faced this issue?


Otherwise a technique I've used in the past is to have a maximum depth of recursion (say 5 or 10) and then in your code

Code (genero) Select
CASE depth
   WHEN 1 OPEN WINDOW w_1 WITH FORM form_name
   WHEN 2 OPEN WINDOW w_2 WITH FORM form_name
   WHEN 3 OPEN WINDOW w_3 WITH FORM form_name
...


... to avoid the horrible duplicate code I would tend to use the pre-processor to avoid typing the duplicate code, something similar to ...

Code (genero) Select
CASE depth
   &define open_window(p1) WHEN p1 OPEN WINDOW w_ ## p1 WITH FORM form_name
   open_window(1)
   open_window(2)
   open_window(3)
...


Code (genero) Select
PS: I think the same reasoning can be applied to cursors, which I think are also global identifiers.


Correct.  However since 3.00 you can use base.SqlHandle for this.  http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassSqlHandle.html

Code (genero) Select
DEFINE cursor_list DYNAMIC ARRAY OF base.SqlHandle

or similar

Hope that helps,

Reuben










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

Sebastien F.

We have often discussed this internally, the feature is identified as FGL-2297

Seb

Luís T.

Thanks for the hints Reuben.

What is "FGL-2297" Sebastien?

Sebastien F.

FGL-2297 is the identifier of the ticket in our bugs/features database.
See https://4js.com/support/issue/?id=FGL-02297#startissue
Seb