The last stage of the app from the series Building a customer app in Uniface 10 added four analysis forms: statistics, ABC analysis, search and settings snapshots. Most of their buttons do the same:
- call a service operation that returns a list,
- walk the rows,
- format one line per row,
- show a text when the list is empty, and a count in the info line.
Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, October 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2).
The template
The forms of this project are written as ProcScript files and imported as XML. For the list entries, a Python function writes the ProcScript:
def listentry(E,name,call,cols,line,empty,info):
vs=', '.join(['vData','vRow','vError','vText']+cols)
gets=''.join(f'\t\tgetitem {c}, vRow, {i+1}\n' for i,c in enumerate(cols))
return f'''entry {name}
variables
numeric vCount
string {vs}
endvariables
activate {call}
if ($status < 0)
INFO.{E} = vError
return -1
endif
vText = ""
forlist vRow in vData
{gets} call ADD_LINE(vText, "{line}")
endfor
if (vText = "")
vText = "{empty}"
endif
RESULT.{E} = vText
INFO.{E} = "{info}"
return 0
end
'''
The call names the entry, the service call, the columns of a row and the text of a line:
ab += listentry(E,'DO_DOMAINS',f'"REPORT3_SVC".DOMAIN_STATS(DMIN.{E}, vData, vCount, vError)',['vDomain','vN'],'%%(vDomain): %%(vN) customer(s)','No domain reaches the minimum.','%%(vCount) domain(s).')
The result
entry DO_DOMAINS
variables
numeric vCount
string vData, vRow, vError, vText, vDomain, vN
endvariables
activate "REPORT3_SVC".DOMAIN_STATS(DMIN.ABC_DMY, vData, vCount, vError)
if ($status < 0)
INFO.ABC_DMY = vError
return -1
endif
vText = ""
forlist vRow in vData
getitem vDomain, vRow, 1
getitem vN, vRow, 2
call ADD_LINE(vText, "%%(vDomain): %%(vN) customer(s)")
endfor
if (vText = "")
vText = "No domain reaches the minimum."
endif
RESULT.ABC_DMY = vText
INFO.ABC_DMY = "%%(vCount) domain(s)."
return 0
end
This is what was imported, compiled (0 errors) and tested. The generator is not needed at runtime; the form contains plain ProcScript.
Why it was worth it
- 17 entries in the four forms came from this function.
- Variable names come from the column list, so a row with five columns cannot be read into four variables by mistake.
- Error handling is the same everywhere: the service's message goes to the info line, the result field keeps its old content.
- A change to the pattern is one change in the function and a rebuild.
Where it stops
Entries that ask a question, write a file or change data were written by hand. They differ in the details that matter: what to ask, when to commit, what to show afterwards. A template for them would need so many parameters that it would be harder to read than the entry itself.
Click test
With four test customers, the generated entries showed for example:
example.com: 2 customer(s)
example.org: 1 customer(s)
Notes
- Generate code only where the pattern is really the same.
- Keep the generated code readable; it is what you debug.
- Check the generated code into the same place as the hand-written code and compare it with the repository after import.
Top comments (0)