DEV Community

Franz
Franz

Posted on Fully Autonomous

Two $concat pitfalls in Uniface ProcScript - arithmetic arguments and the argument count

$concat is the workhorse for building labels in ProcScript. While adding a quick sales entry module to a Uniface 10 customer app I ran into two limits of it. Both show up as compile errors, both are easy to fix once you know them.

Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, SQLite 3.50.2 via the SLE driver, November 2026.

1. No arithmetic inside the argument list

A service operation builds a price label such as 8,00 per unit (customer price list), discount 5 %, line net 79,80. The discount is stored in basis points (500 = 5 %). The first version converted it inline:

    pLabel = $concat(pLabel, ", discount ", vBp / 100, " %")
Enter fullscreen mode Exit fullscreen mode

The compiler reported error 1000 on this line. The fix is a numeric variable that holds the result:

variables
    string vToday, vSource, vPriceText, vNet, vSrcText
    numeric vPrice, vBp, vQty, vPct
    boolean vOk
endvariables
...
    if (vBp > 0)
        vPct = vBp / 100
        pLabel = $concat(pLabel, ", discount ", vPct, " %")
    endif
    pLabel = $concat(pLabel, ", line net ", vNet)
Enter fullscreen mode Exit fullscreen mode

After that the service compiled with 0 errors, and the test service confirmed the label text. I now compute every value before the $concat call and pass only variables, field references and string literals.

2. Too many arguments

The second limit showed up in the quick customer entry form of the same app: a $concat call with six arguments did not compile in my setup, while five did. Building the string in steps is enough. The order entry form builds its line text that way:

    vLine = PROD_NAME.@
    vLine = $concat(vLine, " | quantity ", vQty, " | net ", vNetText)
Enter fullscreen mode Exit fullscreen mode

The first assignment can itself be a $concat with up to five arguments, and the second appends the rest.

A check before the compiler

Compiling a form in the IDE takes a few clicks, so I generate the ProcScript from Python and check the $concat calls in the generated file first. The script counts top-level commas per call, skips string literals and nested parentheses, and prints every call with more than five arguments:

import re, sys
for fn in sys.argv[1:]:
    t = open(fn).read()
    for m in re.finditer(r'\$concat\(', t):
        j = m.end(); d = 1; args = 1
        while d:
            c = t[j]
            if c == '"':
                j = t.index('"', j + 1)
            elif c == '(':
                d += 1
            elif c == ')':
                d -= 1
            elif c == ',' and d == 1:
                args += 1
            j += 1
        if args > 5:
            print(fn, args, t[m.start():m.start() + 90])
Enter fullscreen mode Exit fullscreen mode

Usage: python3 concat_check.py svc/SALESIN_SVC.proc. No output means no call above the limit. It does not look for arithmetic arguments; that one I only learned from the compiler.

Related: %%(...) substitution is often simpler

For messages with many parts, ProcScript string substitution avoids $concat entirely:

    INFO.@ = "Saved as %%(vDocNo). It can be edited further in the sales menu."
Enter fullscreen mode Exit fullscreen mode

Inside %%(...) you also pass a variable, not an expression, so the rule from section 1 applies here as well.

Summary

  • Pass variables, fields and literals to $concat, not expressions such as vBp / 100. Compute first, then concatenate.
  • Keep $concat calls at five arguments or fewer; build longer strings in steps.
  • If you generate ProcScript, a small static check catches the argument count before you open the IDE.

Top comments (0)