andy2609
18th January 2019, 17:45
In a 4GL program script, where multiple form fields require the same checks, is there any way to use wildcards to avoid replication of code for each field? I have a form with 20 data fields of the same type.

Here is a sample of what I would like to avoid having to create for each field:

field.field_01:
before.checks:
field_01 = toupper$(field_01)
check.input:
if not isspace(field_01) then
if not valid.entry(field_01) then
set.input.error("")
endif
endif

field.field_02:
before.checks:
field_02 = toupper$(field_02)
check.input:
if not isspace(field_02) then
if not valid.entry(field_02) then
set.input.error("")
endif
endif

NPRao
18th January 2019, 20:16
Andy,

1 - You can define them as array fields so it makes the checks easier.

2 - You can explore using the predefined variable -
string fattr.currfld$(30) 4R Name of current field.

JaapJD
21st January 2019, 09:22
You can use the field.all section:

domain <some domain> field.value

field.all:
before.checks:
if <this is a field that must be checked> then
get.var(pid, fattr.currfld$, field.value)
field.value = toupper$(field.value)
put.var(pid, fattr.currfld$, field.value)
endif
check.input:
if <this is a field that must be checked> then
if not isspace(field.value) and
not valid.entry(field.value) then
set.input.error("")
endif
endif