Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Ben R. on February 28, 2014, 08:16:23 pm



Title: Programmatically fetching a screen element.
Post by: Ben R. on February 28, 2014, 08:16:23 pm
I feel like there must be a way to do this, but I can't find it. It's easy enough to set the text of a screen element (setElementText), but I can't find an equivalent way to fetch the same element. I've got an application that I want to modify the construct element based on selections made (there are formonly elements and I want to use a specific one conditionally depending upon what else is selected.)

Any thoughts on this?


Title: Re: Programmatically fetching a screen element.
Post by: Reuben B. on March 02, 2014, 08:58:09 pm
I'll make sure you aware of three things that may help ...

1. Multi-Dialog https://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_multiple_dialogs_001.html
So you can end up with
Code
  1. FUNCTION ...
  2.   DIALOG
  3.      INPUT ...
  4.      END INPUT ...
  5.      CONSTRUCT where1 ...
  6.      END CONSTRUCT
  7.      CONSTRUCT where2...
  8.      END CONSTRUCT
  9.      ...
  10.   END DIALOG
  11.   IF ... THEN
  12.      LET sql = ..., where1, "AND ", where2
  13.   ELSE
  14.      LET sql = ..., where1
  15.   END IF
  16. END FUNCTION

OK for simple permutations, at its extreme you'd end up with one construct per field

2. ui.Dialog.getFieldBuffer https://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassDialog_getFieldBuffer.html, returns the value of a field, particular useful in a CONSTRUCT
(GET_FLDBUF() is similar https://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_operators_GET_FLDBUF.html)

Be aware of the difference between buffered and unbuffered  https://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_multiple_dialogs_012.html.  A lot of people get caught out by the fact that in the default buffered mode, the value of the current field inside an ON ACTION hasn't been updated yet.

3. Where there isn't a 4gl method available, sometimes you need to read or write to the AUI tree, see my notes and examples on this topic here https://code.google.com/p/sourcefourjs/wiki/auitree
So at the start of your question you mentioned there is a setElementText() but no getElementText().  Using the techniques mentioned in that article and example is how you would write your own, however the rest of the question suggests that you don't want the value of the text attribute but the value instead.
(also that article/example is 5 years old, there are some things in there that can be done by 4gl methods now)

Hope that helps,

Reuben