The customer app from the series Building a customer app in Uniface 10 had grown to more than a hundred services for sales: products, prices, quotes, orders, invoices, payments, dunning, deliveries, subscriptions, bank statements. None of it had a user interface yet. The next stage was ten new forms with between 11 and 58 fields each - 310 fields in total - plus one new button in the existing main menu.

Painting 310 fields one by one in the form painter is slow, and it is hard to keep a consistent layout. The IDE can export and import repository objects as XML, so the forms were generated as XML and imported instead. This article shows how that worked, what the form picture inside the XML looks like, and the one mistake that crashed the IDE.

Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, October 2026. Paths are shortened to C:\Projects\CustomerApp\.

Start from a real export

The safest template is a form that already works. In the IDE, the menu at the top right (≡) has Export and Import XML.... Exporting one existing modal form gave a file with three tables:

Table Content
UFORM one occurrence: the form itself, with USCRIPT (the ProcScript), UDECLARATIONS (component variables), window size and FORMPIC
UXGROUP one occurrence per entity painted on the form
UXFIELD one occurrence per field: widget type, label, initial value, field script

The forms in this app all follow the same pattern: a non-database dummy entity (PRD_DMY.NOMODEL, DOC_DMY.NOMODEL, ...), labels as non-editable fields, single-line and multi-line edit boxes, and command buttons whose detail trigger calls an entry in the form script:

trigger detail call DO_SAVE end 

So the generator only needs four field kinds. It takes one field occurrence of each kind from the exported template and changes the name, the label, and for buttons the trigger script.

The form picture is text

The interesting part is FORMPIC. It is not binary; it is a text picture of the form, one line per row, and every painted object is a token. The entity token looks like this:

&uFRM;TYP=E&uSEP;NAM=PRD_DMY.NOMODEL&uSEP;WID=96&uSEP;HEI=32&uSEP;HOC=96&uSEP;VOC=32&uFRM; 

and a field token like this:

&uFRM;TYP=F&uSEP;NAM=BTN_SAVE&uSEP;WID=16&uSEP;HEI=1&uFRM; 

The position of a token is its column in the line. WID and HEI are the size in characters and rows. In the template, line 0 was empty, line 1 started with six spaces and the entity token, and the fields followed in the lines below.

The generator builds that picture from a list of rows. This is the code that was used for all ten forms (Python):

def token_e(name, wid, hei): return '&uFRM;TYP=E&uSEP;NAM=%s&uSEP;WID=%d&uSEP;HEI=%d&uSEP;HOC=%d&uSEP;VOC=%d&uFRM;' % (name, wid, hei, wid, hei) def token_f(name, wid, hei): return '&uFRM;TYP=F&uSEP;NAM=%s&uSEP;WID=%d&uSEP;HEI=%d&uFRM;' % (name, wid, hei) def formpic(ent, ewid, ehei, fields): rows = {} for f in fields: rows.setdefault(f['row'], []).append(f) lines = ['', ' ' + token_e(ent + '.NOMODEL', ewid, ehei)] maxrow = max(f['row'] + f['h'] - 1 for f in fields) for r in range(1, maxrow + 1): line = '' cur = 0 for f in sorted(rows.get(r, []), key=lambda x: x['col']): c = f['col'] + 6 assert c >= cur, (f['name'], c, cur) line += ' ' * (c - cur) + token_f(f['name'], f['w'], f['h']) cur = c + f['w'] lines.append(line) 

(The function ends by joining the lines with line breaks; the XML writer escapes & and writes the file as UTF-8 with BOM and CRLF, like the export.)

A layout is then just a list. This is the first block of the product form:

build('PRODUCT_FRM', 'PRD_DMY', [ (1, [('LBL_SEARCH', L, 14), ('SEARCH', E, 30), ('BTN_SEARCH', B, 12), ('BTN_SEARCH_ALL', B, 24)]), (2, [('RESULT', M, 92, 8)]), ... 

The + 6 that crashed the IDE

The first version did not have + 6. It placed the first field of each row at column 2 - which looked right, because in the painter the fields start just inside the entity frame.

The import reported success. Opening the form in the IDE did not:

Unhandled Exception Error code -100000 Description Coding error ERROR -10104 <UINTERNALERROR> Internal error COMPONENT UC_CPT PROCNAME 109\GETPAINT PROCLINE interrupt 22, FORMPIC.UFORM 

The details pointed straight at FORMPIC. Comparing the generated picture with the template showed the difference: the entity token starts at column 6, and in the template the fields start at column 8. Column 2 put every field to the left of its own entity frame. The IDE does not validate that on import; it fails later, when it paints the form.

The dialog offers Exit and Ignore. Exit plus a restart of the IDE was the clean way out. After the fix (field columns relative to the entity, + 6), the corrected XML was imported over the broken form and opened normally.

Two lessons from this:

  • An import that succeeds is not a form that works. Always open and compile the imported object straight away.
  • Check the generator against a real export, not against your idea of the format.

A round-trip test for the generator

The second lesson became a test. A small parser reads the FORMPIC of the exported template back into a field list (name, row, column, width, height). Feeding that list into formpic() must give the original picture back, character for character. After the column fix, the round trip for the template form was identical. If the generator ever drifts from what the IDE writes, this test notices before the IDE does.

What else needed care

  • Button labels. The template's buttons all had the initial value "Button text". The forms set their labels in an entry SET_LABELS called from exec, so the XML did not need a label per button.
  • Default field triggers. Edit fields in the template carried a default onEdit trigger script. The generator drops it; the forms don't need it.
  • The import dialog. It sometimes closed itself after an import and sometimes stayed open. Typing the next file name without checking the dialog first sent the text into whatever had focus - once the open script editor. Check the dialog before typing.
  • Compile every form after import. Each of the ten forms (and the changed main menu) compiled with 0 errors and one warning: 1016, the dummy entity is not in the application model. That warning is expected for non-database entities.

Result

Ten forms, 310 fields, all generated from layout lists and the ProcScript source files. When a form needed a change - a label, a new button, a bug fix in the script - the source file changed, the XML was generated again and imported over the old form. After every import, the script in the repository was compared with the source file; all of them were identical.

The XML route does not replace the painter for a form that needs careful visual design. For many similar forms with a fixed pattern, it turned a lot of clicking into a list per form, and it made the layout reviewable as text.