Hi, Stephen
The issue under discussion is:
------------------------------------------------
Would it be possible to add a field'state() array to the .gen file that get used by the handle'controls routine for SBXINP controls. You could set the defaults to whatever they are setup as in the properties panel in LEO.
The reason I ask is there are a lot of times when I need to have a dialog with a lot of sbxinp fields start in DISPLAY_MODE with one in EDIT_MODE. This is generally so that the editable field is a File Key selection. Once the key is selected I'll put that control in DISPLAY_MODE and all the others in EDIT_MODE. It seems that it would be much cleaner to do this if the program knows what the state of the SBXINP control should be and then just call refresh'controls().
---------------------------------------
I think the images below illustrate the scenario, that is, fields changing their sates depending on some condition, correct?
In the above example, the three marked fields start enabled and, depending on the 2nd field they are disabled, or not.
The control of the field state is prepared in Leo allowing to fully control the field state in the main program, to do that:
Ticking the "REFRESH control" checkbox for each of the fields we want to control (i.e. change state, refresh value) inform LEO to ceate DEFINES using their "Name", like:
! control # for fields requiring individual REFRESH actions
define cursos_PROJ'ID = -102
define cursos_PRGFIN = -104
define cursos_TAB'CLI = -106
define cursos_ARFOR = -109
define cursos_EFORM = -111
define cursos_EDICAO = -113
With this, if I need to refresh one particular field (eg: PRGFIN) regarding its value, just need to do:
call cursos_refresh'controls(cursos_PRGFIN, cursos_PRGFIN)
If I want to control the state depending on a condition, I use the "_fld'pre" procedure that, for the above example looks like this:
PROCEDURE cursos_fld'pre(op as b1,fname$ as s24,do'nothing as b1)
++pragma auto_extern
STRSIZ 24 ! needed for the SWITCH evaluation
if op=DISPLAY_MODE then ! only on display
SWITCH fname$
CASE "curso.prfin"
op = state.prgfin
exit
CASE "sccrnovo.tab'curso"
op = state'tipologia
exit
CASE "sccrnovo.tab'cli"
op = state'cliente
exit
DEFAULT
exit
ENDSWITCH
else
if modo'actual$=MODE_VIEW then
do'nothing = 1
else
SWITCH fname$
DEFAULT
exit
ENDSWITCH
endif
endif
xputarg 1,op
xputarg 2,fname$
xputarg 3,do'nothing
ENDPROCEDURE
The logic above do this:
When _refresh'controls() is processed in DISPLAY_MODE (like in the initial load dialog), the three fiels will have the state defined in the corresponding state variables (eg: EDIT_MODE, DISABLE_MODE, DISPLAY_MODE; all those defined in LEO) that you can set as you want in the main program.
In my example, when in MODE_VIEW (not editing), I want to not allow ANY field to be entered so, setting "do'nothing = 1" does the job.
Surely what is described above is more than what you asked for and, maybe even don't completely answer your needs, but my goal here is to show that, the logic to enable/disable/refresh fields is already available in LEO, and now it's just a matter to adjust it.
I don't know if you knew already this technique and, besides that, it doesn't cover what you want or, you never tried it.
Please let me know what is your case, and I'll adjust whatever is needed.
Thank you