<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Franz</title>
    <description>The latest articles on DEV Community by Franz (@f345345dfg).</description>
    <link>https://dev.to/f345345dfg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3671581%2F5f7f5670-e10e-4728-861f-ef8b79ab638c.png</url>
      <title>DEV Community: Franz</title>
      <link>https://dev.to/f345345dfg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/f345345dfg"/>
    <language>en</language>
    <item>
      <title>Restoring a draft over rows that are reloaded from the database - Uniface grid forms</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Tue, 17 Nov 2026 13:56:12 +0000</pubDate>
      <link>https://dev.to/f345345dfg/restoring-a-draft-over-rows-that-are-reloaded-from-the-database-uniface-grid-forms-5251</link>
      <guid>https://dev.to/f345345dfg/restoring-a-draft-over-rows-that-are-reloaded-from-the-database-uniface-grid-forms-5251</guid>
      <description>&lt;p&gt;In an earlier step, the quick entry forms of a Uniface 10 customer app got drafts. In those forms the user types every row, so loading a draft means creating the rows again. The goods receipt, delivery note and ticket forms are different: their rows come from the database (open purchase order lines, open order lines, open tickets), and the user only fills in a few columns. A draft for those forms has to keep the rows the database provides and only put the user's input back.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the draft file contains
&lt;/h2&gt;

&lt;p&gt;The format is the same as before, one value per line, &lt;code&gt;0&lt;/code&gt; for the header:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#draft 17.11.2026 13:14
0|F_PO|TS41-P1
0|F_WH|T41A
0|F_DATE|
1|L_LINE|4100001
1|L_QTY|6
2|L_LINE|4100002
2|L_QTY|3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only rows with a quantity are written, and each row carries its key, the purchase order line ID.&lt;/p&gt;

&lt;h2&gt;
  
  
  Header first, through the normal entries
&lt;/h2&gt;

&lt;p&gt;The header values are not just copied into the fields. Each one is set and then the same entry runs that runs when the user leaves the field. &lt;code&gt;LEAVE_PO&lt;/code&gt; finds the order and loads its open lines, &lt;code&gt;LEAVE_WH&lt;/code&gt; checks the warehouse:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry DRAFT_HEADER
params
    string pHead : IN
endparams
variables
    string vV
endvariables
    vV = ""
    getitem/id vV, pHead, "F_PO"
    F_PO.QRC_HDR = vV
    call LEAVE_PO
    vV = ""
    getitem/id vV, pHead, "F_WH"
    F_WH.QRC_HDR = vV
    call LEAVE_WH
    vV = ""
    getitem/id vV, pHead, "F_DATE"
    F_DATE.QRC_HDR = vV
    call LEAVE_DATE
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order matters: the purchase order loads the rows, so it comes first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rows by key, not by position
&lt;/h2&gt;

&lt;p&gt;Since the open lines were just reloaded, their positions may differ from the time the draft was saved, and lines may already be fully received. Each saved row is looked up by its line ID, the value is set, and the normal row check runs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry DRAFT_ROW
params
    string pVals : IN
    numeric pFound : OUT
endparams
variables
    string vKey, vV
    numeric vI, vN
endvariables
    pFound = 0
    vKey = ""
    getitem/id vKey, pVals, "L_LINE"
    if (vKey = "")
        return 0
    endif
    vN = $totocc(QRC_LIN)
    vI = 1
    while (vI &amp;lt;= vN &amp;amp; pFound = 0)
        setocc "QRC_LIN", vI
        if (L_LINE.QRC_LIN = vKey)
            pFound = vI
        endif
        vI = vI + 1
    endwhile
    if (pFound = 0)
        return 0
    endif
    vV = ""
    getitem/id vV, pVals, "L_QTY"
    L_QTY.QRC_LIN = vV
    call CHECK_ROW
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The caller counts &lt;code&gt;pFound = 0&lt;/code&gt;, and the form says "2 row(s), 1 row(s) are no longer open" instead of dropping input without a word.&lt;/p&gt;

&lt;p&gt;The values are collected per row: one id list (&lt;code&gt;putitem/id&lt;/code&gt;) per saved row, handed to &lt;code&gt;DRAFT_ROW&lt;/code&gt; when the row number in the file changes. A single id list for all rows would not work, because row 2 would overwrite the &lt;code&gt;L_QTY&lt;/code&gt; of row 1.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the app's own CSV exports
&lt;/h2&gt;

&lt;p&gt;The forms can export their rows as CSV with &lt;code&gt;;&lt;/code&gt; and quoted values. To let users edit such a file in a spreadsheet and load it again, the service needs to split a CSV line correctly - a product name like &lt;code&gt;TS41 nut; small&lt;/code&gt; arrives in quotes. ProcScript has no CSV parser, so here is a small one that walks the line character by character. The quote character comes from SQL because a double quote cannot be written inside a ProcScript string literal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;operation&lt;/span&gt; &lt;span class="no"&gt;CSV_SPLIT&lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pLine&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pValues&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
&lt;span class="n"&gt;endparams&lt;/span&gt;
&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vQ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vCur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNext&lt;/span&gt;
    &lt;span class="n"&gt;numeric&lt;/span&gt; &lt;span class="n"&gt;vI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vJ&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
    &lt;span class="n"&gt;pValues&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT char(34) AS Q"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vQ&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;vCur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;vIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;vN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pLine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;vN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pLine&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;vI&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vQ&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;vJ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="n"&gt;vNext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vJ&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;vN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;vNext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pLine&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;vJ&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="n"&gt;endif&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vNext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vQ&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;vCur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vCur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vQ&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="k"&gt;else&lt;/span&gt;
                    &lt;span class="n"&gt;vIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
                &lt;span class="n"&gt;endif&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;
                &lt;span class="n"&gt;vCur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vCur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vQ&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;vIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;elseif&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;";"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pValues&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vCur&lt;/span&gt;
                &lt;span class="n"&gt;vCur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;
                &lt;span class="n"&gt;vCur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vCur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endwhile&lt;/span&gt;
    &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pValues&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vCur&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The load operation reads the header line, looks for a column named &lt;code&gt;Article&lt;/code&gt; and a quantity column (&lt;code&gt;Quantity&lt;/code&gt;, &lt;code&gt;Counted or quantity&lt;/code&gt;, &lt;code&gt;Receive now&lt;/code&gt;), and turns every data line into &lt;code&gt;ARTICLE QUANTITY&lt;/code&gt;. That text then goes through the same parser as pasted lists. Files without such a header are passed through as a plain list.&lt;/p&gt;

&lt;p&gt;Inside the service, &lt;code&gt;CSV_SPLIT&lt;/code&gt; is a public operation, so the load operation runs it with &lt;code&gt;activate $instancename.CSV_SPLIT(vLine, vValues)&lt;/code&gt;. A plain &lt;code&gt;call&lt;/code&gt; is for entries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;A self-checking service covers the splitter (simple line, quotes and separators inside values, empty values in place), reading an exported purchase order list and a stock list, a plain list, a missing file, a file with only a header, and read-only rights. The forms were clicked through on a copy of the database: a goods receipt draft restored onto reloaded order lines, a CSV with a quoted name containing &lt;code&gt;;&lt;/code&gt;, and a purchase order export loaded back in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;For drafts over database rows, replay the header through the normal leave entries, then lay the saved values onto rows found by key.&lt;/li&gt;
&lt;li&gt;Keep one id list per saved row.&lt;/li&gt;
&lt;li&gt;Report rows that no longer exist instead of dropping them.&lt;/li&gt;
&lt;li&gt;A character loop is enough for a CSV splitter; get the quote character from SQL.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>csv</category>
      <category>legacy</category>
    </item>
    <item>
      <title>Spreadsheet paste, drafts and sorting for Uniface grid forms</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Tue, 17 Nov 2026 11:55:03 +0000</pubDate>
      <link>https://dev.to/f345345dfg/spreadsheet-paste-drafts-and-sorting-for-uniface-grid-forms-17pp</link>
      <guid>https://dev.to/f345345dfg/spreadsheet-paste-drafts-and-sorting-for-uniface-grid-forms-17pp</guid>
      <description>&lt;p&gt;A Uniface 10 customer app has a few quick entry forms with a grid: purchase order lines, stock counts, appointments. Typing works. In practice, though, the lines often already exist in a spreadsheet. Sometimes the user gets interrupted halfway through, and sometimes the rows end up in a random order. This post covers the three additions that took care of that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;paste a list from a spreadsheet and turn it into grid rows&lt;/li&gt;
&lt;li&gt;save a draft and offer it when the form opens again&lt;/li&gt;
&lt;li&gt;sort the rows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pasting a list
&lt;/h2&gt;

&lt;p&gt;A multi-line edit box below the grid takes whatever the user pastes. A button hands the text to a service. The service returns one item per good line (&lt;code&gt;id/article/quantity&lt;/code&gt;), plus a count of bad lines and their messages.&lt;/p&gt;

&lt;p&gt;Spreadsheet cells arrive separated by tabs. Some users type &lt;code&gt;;&lt;/code&gt; instead, and Windows adds a carriage return. Rather than handling each case in ProcScript, the service lets SQLite normalise the line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cfscript"&gt;&lt;code&gt;        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SQL_ESCAPE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vLine&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT TRIM(REPLACE(REPLACE(REPLACE(REPLACE('%%(vLine)', char(9), ' '), char(13), ' '), ';', ' '), '  ', ' ')) AS L"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, a line is either &lt;code&gt;ARTICLE&lt;/code&gt; (quantity 1) or &lt;code&gt;ARTICLE QUANTITY&lt;/code&gt;, separated by one space. Lines are split on &lt;code&gt;%%^&lt;/code&gt;, the ProcScript line break.&lt;/p&gt;

&lt;p&gt;The form creates one occurrence per good line and then calls the same entry that runs when the user leaves the article cell. Name, unit, price and checks therefore come from exactly the same code as manual entry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight abap"&gt;&lt;code&gt;        &lt;span class="n"&gt;creocc&lt;/span&gt; &lt;span class="s2"&gt;"QPO_LIN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SETUP_ROW&lt;/span&gt;
        &lt;span class="no"&gt;L_SKU&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vSku&lt;/span&gt;
        &lt;span class="no"&gt;L_QTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vQty&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;LEAVE_LSKU&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The messages go back into the edit box, so the user sees &lt;code&gt;Line 5: no article NOPE.&lt;/code&gt; right where the pasted text was.&lt;/p&gt;

&lt;h3&gt;
  
  
  A bug the test found
&lt;/h3&gt;

&lt;p&gt;The first version lost the first error message. Each line looks up its article through a helper that has its own error parameter. I passed the service's OUT parameter to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;call READ_ROWS("SELECT ... LIMIT 1", vData, vCount, pErrors)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The helper clears its error parameter on every call. So line 6 wiped out the message collected for line 5. The test expected three bad lines and three messages, and got three bad lines but only two messages. The fix is a local variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                call READ_ROWS("SELECT PRODUCT_ID AS ID, SKU AS S, COALESCE(IS_ACTIVE, 1) AS A FROM PRODUCT WHERE UPPER(SKU) = '%%(vSku)' LIMIT 1", vData, vCount, vReadErr)
                if (vData = "" &amp;amp; vReadErr != "")
                    vErr = "Line %%(vN): %%(vReadErr)"
                elseif (vData = "")
                    vErr = "Line %%(vN): no article %%(vSku)."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lesson: never pass an OUT parameter you are still building up into another call.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drafts as a small text file
&lt;/h2&gt;

&lt;p&gt;No schema changes were allowed, so drafts go into a text file per form and user in the export folder. The format is deliberately simple, one value per line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#draft 17.11.2026 12:42
0|F_USER|tst_admin
1|L_CUST|4200001
1|L_DATE|2026-11-18
1|L_TIME|14:00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;0&lt;/code&gt; is the header and every other number is a grid row. Writing the file is a loop over the occurrences with &lt;code&gt;$concat&lt;/code&gt;, followed by a service call that adds the timestamp line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        vText = $concat("#draft ", vNow, "%%^", pText)
    endif
    call WRITE_FILE(vText, vFile, pError)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the form opens, the draft is offered with &lt;code&gt;askmess/question&lt;/code&gt;. Loading it uses the same trick as pasting: set the raw values, then run the normal &lt;code&gt;loseFocus&lt;/code&gt; entries. Header first, then each row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vOcc&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;vOcc&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vHdr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;LEAVE_USER&lt;/span&gt;
                &lt;span class="n"&gt;vHdr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;endif&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vOcc&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;vLast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vLast&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;LEAVE_LCUST&lt;/span&gt;
                &lt;span class="n"&gt;endif&lt;/span&gt;
                &lt;span class="n"&gt;creocc&lt;/span&gt; &lt;span class="s2"&gt;"QAP_LIN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
                &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SETUP_ROW&lt;/span&gt;
                &lt;span class="n"&gt;vLast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vOcc&lt;/span&gt;
            &lt;span class="n"&gt;endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order matters. In the appointment form, the row check needs the user from the header, so the header entry has to run before the first row is replayed, not after the loop.&lt;/p&gt;

&lt;p&gt;After a successful save, the form writes an empty draft. &lt;code&gt;DRAFT_LOAD&lt;/code&gt; returns nothing for a file that does not start with &lt;code&gt;#draft&lt;/code&gt;, so no delete permission is needed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sorting occurrences
&lt;/h2&gt;

&lt;p&gt;My first attempt was &lt;code&gt;sort/e&lt;/code&gt;. It works, but Uniface 10.4 reports it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(DO_SORT) warning:  1000 - Deprecated statement 'sort/e' used
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plain &lt;code&gt;sort&lt;/code&gt; with the entity name and a field sorts the occurrences in ascending order. Empty rows are removed first, so they do not end up at the top:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry DO_SORT
    call VALIDATE_CURRENT
    call DROP_EMPTY
    if ($totocc(QAP_LIN) &amp;lt; 1)
        creocc "QAP_LIN", -1
        call SETUP_ROW
    endif
    sort "QAP_LIN", "L_START"
    setocc "QAP_LIN", 1
    call SHOW_TOTAL
    INFO.QAP_FTR = "Rows sorted by start."
    return 0
end

entry DROP_EMPTY
variables
    numeric vI
endvariables
    vI = $totocc(QAP_LIN)
    while (vI &amp;gt;= 1)
        setocc "QAP_LIN", vI
        if (L_CUST.QAP_LIN = "")
            remocc "QAP_LIN", 0
        endif
        vI = vI - 1
    endwhile
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;DROP_EMPTY&lt;/code&gt; loops backwards, because &lt;code&gt;remocc&lt;/code&gt; shifts the occurrences that follow. &lt;code&gt;VALIDATE_CURRENT&lt;/code&gt; is needed because clicking a button does not fire &lt;code&gt;loseFocus&lt;/code&gt; for the cell the user just edited.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;A self-checking service runs 18 checks against the list service: parsing, merging duplicates, CSV quoting, writing and reading a draft, and shifting a start time. The data uses its own ID range and everything is rolled back at the end. The forms were then clicked through by hand on a copy of the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Normalise pasted text with SQL &lt;code&gt;REPLACE&lt;/code&gt; and keep the ProcScript parsing simple.&lt;/li&gt;
&lt;li&gt;Fill grid rows by setting raw values and calling the same entries as manual entry.&lt;/li&gt;
&lt;li&gt;Keep drafts in a plain &lt;code&gt;index|FIELD|value&lt;/code&gt; file. Replay the header before the rows.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;sort "ENTITY", "FIELD"&lt;/code&gt; instead of the deprecated &lt;code&gt;sort/e&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Do not reuse an OUT parameter you are collecting into as the error output of a helper.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>lowcode</category>
      <category>legacy</category>
    </item>
    <item>
      <title>Let users jump to the target status - generating ProcScript status paths from a small state graph</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Tue, 17 Nov 2026 11:53:37 +0000</pubDate>
      <link>https://dev.to/f345345dfg/let-users-jump-to-the-target-status-generating-procscript-status-paths-from-a-small-state-graph-2704</link>
      <guid>https://dev.to/f345345dfg/let-users-jump-to-the-target-status-generating-procscript-status-paths-from-a-small-state-graph-2704</guid>
      <description>&lt;p&gt;A Uniface 10 customer app has service tickets with five statuses. The existing ticket service enforces the allowed steps, which is good: every change is checked and written to a status log. For quick entry it is annoying, though. To close a ticket that is still open, a user has to go to "in progress", then "solved", then "closed" - three saves for one decision.&lt;/p&gt;

&lt;p&gt;The quick entry form for tickets now lets the user type the target status (&lt;code&gt;S&lt;/code&gt; for solved, &lt;code&gt;C&lt;/code&gt; for closed) and walks the steps in between. The steps themselves still go through the existing service, so nothing bypasses its checks or its log.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The allowed steps
&lt;/h2&gt;

&lt;p&gt;The ticket service has an entry that says which single step is allowed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"OPEN"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;pOk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"WAITING"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SOLVED"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;pOk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and so on for WAITING and SOLVED. CLOSED is final.&lt;/p&gt;

&lt;h2&gt;
  
  
  Shortest paths, computed once
&lt;/h2&gt;

&lt;p&gt;ProcScript has no queue type, and a breadth-first search in item lists would be hard to read. The graph is tiny and fixed, so I compute all shortest paths in the Python script that generates the service, and write them out as a chain of &lt;code&gt;if&lt;/code&gt; blocks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;STEPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'OPEN'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'IN_PROGRESS'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'IN_PROGRESS'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'WAITING'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'SOLVED'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'WAITING'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'IN_PROGRESS'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'SOLVED'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'SOLVED'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'CLOSED'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'IN_PROGRESS'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'CLOSED'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;deque&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deque&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;popleft&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;STEPS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;span class="no"&gt;PATHS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;STEPS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;STEPS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="no"&gt;PATHS&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'\tif (pOld = "%s" &amp;amp; pNew = "%s")\n'&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'\t\tputitem pSteps, -1, "%s"\n'&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'\tendif\n'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The generated operation is boring, which is the point. A part of it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;operation&lt;/span&gt; &lt;span class="no"&gt;STATUS_PATH&lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
&lt;span class="n"&gt;endparams&lt;/span&gt;
    &lt;span class="n"&gt;pSteps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"OPEN"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"OPEN"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"WAITING"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"WAITING"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"OPEN"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SOLVED"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"SOLVED"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pOld&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"OPEN"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;pNew&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"CLOSED"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"IN_PROGRESS"&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"SOLVED"&lt;/span&gt;
        &lt;span class="n"&gt;putitem&lt;/span&gt; &lt;span class="n"&gt;pSteps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CLOSED"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and it ends with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if (pSteps = "")
        pError = "The status cannot change from %%(pOld) to %%(pNew)."
        return -1
    endif
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pairs without a path (anything out of CLOSED, anything back to OPEN) simply produce no &lt;code&gt;if&lt;/code&gt; block and end in that error. If the allowed steps ever change, I change &lt;code&gt;STEPS&lt;/code&gt; and generate again; nobody has to re-derive the paths by hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Walking the path
&lt;/h2&gt;

&lt;p&gt;The save operation of the quick entry receives all changed rows at once. For each row it gets the steps from the same check that the form uses for its preview, and then calls the existing service once per step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;        &lt;span class="n"&gt;forlist&lt;/span&gt; &lt;span class="n"&gt;vStep&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vSteps&lt;/span&gt;
            &lt;span class="n"&gt;activate&lt;/span&gt; &lt;span class="s2"&gt;"TICKET_SVC"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SET_TICKET_STATUS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vStep&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT TICKET_NO AS N FROM TICKET WHERE TICKET_ID = %%(vId)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"%%(vNo): %%(pError)"&lt;/span&gt;
                &lt;span class="n"&gt;rollback&lt;/span&gt;
                &lt;span class="n"&gt;pCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;endif&lt;/span&gt;
            &lt;span class="n"&gt;vDone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;endfor&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because every step goes through &lt;code&gt;SET_TICKET_STATUS&lt;/code&gt;, the status log contains one entry per step, exactly as if the user had clicked through them. The test service checks that: solving an open ticket leaves two log entries. If any step of any row fails, the whole save rolls back.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the user sees
&lt;/h2&gt;

&lt;p&gt;When the user leaves the "new status" cell, the row is checked and the hint line explains what will happen, for example &lt;code&gt;status IN_PROGRESS &amp;gt; SOLVED assign: tst_admin time: 90 min&lt;/code&gt;. Nothing is written until the user saves with Ctrl+A.&lt;/p&gt;

&lt;h2&gt;
  
  
  A note on passing rows with free text
&lt;/h2&gt;

&lt;p&gt;Each changed row travels to the service as one item: &lt;code&gt;ticketId/status/assignee/minutes/note&lt;/code&gt;. The service splits the first four fields at &lt;code&gt;/&lt;/code&gt; and takes the rest as the note, so a note may contain &lt;code&gt;/&lt;/code&gt; itself. Putting the one free-text field last avoids an escaping scheme.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep the single-step rules where they are; add a path on top instead of loosening them.&lt;/li&gt;
&lt;li&gt;For a small, fixed state graph, compute the paths in the generator and emit plain &lt;code&gt;if&lt;/code&gt; blocks. The ProcScript stays trivial and the graph lives in one place.&lt;/li&gt;
&lt;li&gt;Walk the path through the existing service so checks and logs stay complete, and roll back the whole batch on the first error.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>python</category>
      <category>statemachine</category>
    </item>
    <item>
      <title>Row lists without a database table in Uniface 10 - grid entities, per-row triggers and two surprises</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Tue, 17 Nov 2026 11:50:29 +0000</pubDate>
      <link>https://dev.to/f345345dfg/row-lists-without-a-database-table-in-uniface-10-grid-entities-per-row-triggers-and-two-surprises-2mop</link>
      <guid>https://dev.to/f345345dfg/row-lists-without-a-database-table-in-uniface-10-grid-entities-per-row-triggers-and-two-surprises-2mop</guid>
      <description>&lt;p&gt;Order entry forms need lines: article, quantity, price, net. In an earlier version of a Uniface 10 customer app the lines lived in a text field fed from item lists. That works, but nobody can correct line 3 directly. This article shows the version with a real row list: a non-database entity shown as a grid, with triggers per row and nothing written to the database until the user saves.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The grid entity
&lt;/h2&gt;

&lt;p&gt;The form has three non-database entities: a header (supplier, note, delivery date), the lines, and a footer (total, buttons). The IDE palette calls the line entity "Non-DBMS Entity: Grid". In an XML export it is a normal entity of the form with one extra property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ULABEL"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;QPO_LIN&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"UBASE"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;NOMODEL&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"UFORM"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;QPO_FRM&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"UKVERSION"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;7&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"UMVERSION"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;4&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"U_BORD"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;N&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"FRM_WIDGETTYPE"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;EGRID&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The column headers are label entries in the form's layout, one line above the fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;uFRM;TYP=E&amp;amp;uSEP;NAM=QPO_LIN.NOMODEL&amp;amp;uSEP;WID=110&amp;amp;uSEP;HEI=11&amp;amp;uSEP;HOC=110&amp;amp;uSEP;VOC=11&amp;amp;uFRM;
  &amp;amp;uFRM;TYP=L&amp;amp;uSEP;NAM=L_SKU&amp;amp;uSEP;WID=13&amp;amp;uSEP;HEI=1&amp;amp;uSEP;LAB=Article&amp;amp;uFRM; ...
  &amp;amp;uFRM;TYP=F&amp;amp;uSEP;NAM=L_SKU&amp;amp;uSEP;WID=13&amp;amp;uSEP;HEI=1&amp;amp;uFRM; ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I generate these forms from Python, so this was the part to get right; in the IDE you simply drop the grid template on the form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rows
&lt;/h2&gt;

&lt;p&gt;Rows are occurrences of the entity. Adding one appends an occurrence and makes it the current one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight q"&gt;&lt;code&gt;&lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="no"&gt;DO_ADDROW&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;VALIDATE_CURRENT&lt;/span&gt;
    &lt;span class="n"&gt;creocc&lt;/span&gt; &lt;span class="s2"&gt;"QPO_LIN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SETUP_ROW&lt;/span&gt;
    &lt;span class="no"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_FTR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Row %%($curocc(QPO_LIN)) added."&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A click into a row makes that row current, so "Remove row" removes exactly the row the user clicked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry DO_DELROW
variables
    numeric vCur
endvariables
    vCur = $curocc(QPO_LIN)
    remocc "QPO_LIN", 0
    if ($totocc(QPO_LIN) &amp;lt; 1)
        creocc "QPO_LIN", -1
        call SETUP_ROW
    endif
    call SHOW_TOTAL
    INFO.QPO_FTR = "Row %%(vCur) removed."
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Triggers per row
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;loseFocus&lt;/code&gt; trigger on a grid field runs for the row the user just left. Field references without an occurrence number refer to that row, and &lt;code&gt;$curocc&lt;/code&gt; tells you which one it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="k"&gt;entry&lt;/span&gt; &lt;span class="no"&gt;CHECK_ROW&lt;/span&gt;
&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vQty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vHint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;
    &lt;span class="n"&gt;numeric&lt;/span&gt; &lt;span class="n"&gt;vNet&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;L_PID&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;activate&lt;/span&gt; &lt;span class="s2"&gt;"PURIN_SVC"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PO_LINE_CHECK&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;cSup&lt;/span&gt;$&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;L_PID&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;L_QTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;L_PRICE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vQty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vHint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="no"&gt;L_NET&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
        &lt;span class="no"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_FTR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Row %%($curocc(QPO_LIN)): %%(vError)"&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SHOW_TOTAL&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="no"&gt;L_QTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vQty&lt;/span&gt;
    &lt;span class="no"&gt;L_PRICE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vPrice&lt;/span&gt;
    &lt;span class="n"&gt;sql&lt;/span&gt; &lt;span class="s2"&gt;"SELECT REPLACE(printf('%.2f', %%(vNet) / 100.0), '.', ',') AS T"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CUSTOMERS"&lt;/span&gt;
    &lt;span class="no"&gt;L_NET&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QPO_LIN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="n"&gt;result&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SHOW_TOTAL&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The running total walks over all rows inside the same trigger. I was not sure whether moving the current occurrence inside &lt;code&gt;loseFocus&lt;/code&gt; would disturb where the cursor goes next. It does not, as long as the loop puts the old row back at the end:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    vCur = $curocc(QPO_LIN)
    vN = $totocc(QPO_LIN)
    vI = 1
    while (vI &amp;lt;= vN)
        setocc "QPO_LIN", vI
        if (L_PID.QPO_LIN != "")
            L_PRICE.QPO_LIN = ""
            call CHECK_ROW
        endif
        vI = vI + 1
    endwhile
    if (vCur &amp;gt; 0)
        setocc "QPO_LIN", vCur
    endif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(This loop is the one that re-prices all rows after the supplier changed.) In the click test the cursor always landed in the cell the user had clicked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Surprise 1: field properties belong to a row
&lt;/h2&gt;

&lt;p&gt;The name, unit and net columns are read-only. The first version set that once in &lt;code&gt;exec&lt;/code&gt;. The first row was read-only, every row added later was editable again. The same happened with &lt;code&gt;DblClk=Detail&lt;/code&gt;, which makes a double-click in an edit box fire the &lt;code&gt;detail&lt;/code&gt; trigger: the article suggestions worked in row 1 and nowhere else.&lt;/p&gt;

&lt;p&gt;Both &lt;code&gt;$fieldsyntax&lt;/code&gt; and &lt;code&gt;$fieldproperties&lt;/code&gt; act on the field in the current occurrence. So they go into an entry that runs after every &lt;code&gt;creocc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry SETUP_ROW
    $fieldsyntax(L_PID.QPO_LIN) = "NED"
    $fieldsyntax(L_NAME.QPO_LIN) = "NED"
    $fieldsyntax(L_UNIT.QPO_LIN) = "NED"
    $fieldsyntax(L_NET.QPO_LIN) = "NED"
    $fieldproperties(L_SKU.QPO_LIN) = "DblClk=Detail"
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A side note: the older statement &lt;code&gt;fieldsyntax L_NAME.QPO_LIN, "NED"&lt;/code&gt; still compiles, but the compiler reports it as deprecated (warning 1008). The &lt;code&gt;$fieldsyntax&lt;/code&gt; function does the same without the warning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Surprise 2: a button click does not fire loseFocus
&lt;/h2&gt;

&lt;p&gt;In the click test I typed an article number and clicked "Add row" right away. The new row appeared, but the row I had just typed in was never checked: no name, no price. Leaving a cell by clicking a button did not fire the cell's &lt;code&gt;loseFocus&lt;/code&gt; trigger.&lt;/p&gt;

&lt;p&gt;The fix is cheap. Every button that relies on checked rows first checks the current row again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry VALIDATE_CURRENT
    if (L_SKU.QPO_LIN != "")
        call LEAVE_LSKU
    endif
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;DO_ADDROW&lt;/code&gt; above calls it, and so does the save entry behind Ctrl+A. The save itself refuses rows that are still marked as wrong, so a half-checked line never reaches the service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Saving
&lt;/h2&gt;

&lt;p&gt;The save collects all filled rows into one item list (&lt;code&gt;productId/quantity/price&lt;/code&gt;) and passes it to one service operation. That operation creates the purchase order through the existing purchasing service and rolls back if any line fails, so the user either gets the whole order or none of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A non-database entity with &lt;code&gt;FRM_WIDGETTYPE = EGRID&lt;/code&gt; gives an editable row list; &lt;code&gt;creocc&lt;/code&gt;, &lt;code&gt;remocc "ENT", 0&lt;/code&gt;, &lt;code&gt;$totocc&lt;/code&gt;, &lt;code&gt;$curocc&lt;/code&gt; and &lt;code&gt;setocc&lt;/code&gt; do the rest.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loseFocus&lt;/code&gt; on a grid field runs per row. A loop over all rows inside the trigger is fine if it restores the current row.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$fieldsyntax&lt;/code&gt; and &lt;code&gt;$fieldproperties&lt;/code&gt; are per occurrence: set them for every new row.&lt;/li&gt;
&lt;li&gt;Clicking a button does not fire &lt;code&gt;loseFocus&lt;/code&gt; of the cell you were in. Check the current row again before acting on the rows.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>desktop</category>
      <category>forms</category>
    </item>
    <item>
      <title>A quick order entry form in Uniface 10 - item lists in component variables and a price preview on loseFocus</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:29:52 +0000</pubDate>
      <link>https://dev.to/f345345dfg/a-quick-order-entry-form-in-uniface-10-item-lists-in-component-variables-and-a-price-preview-on-1170</link>
      <guid>https://dev.to/f345345dfg/a-quick-order-entry-form-in-uniface-10-item-lists-in-component-variables-and-a-price-preview-on-1170</guid>
      <description>&lt;p&gt;A Uniface 10 customer app already had a full sales document form. For the common case, "customer calls, wants two items", it was too slow. So I added a small entry form: customer number, Q or O for quote or order, article number, quantity, Add line, Ctrl+A. This article shows the parts that were new to me.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;The form has no database entity. The lines live in three component variables, each a Uniface item list (GOLD &lt;code&gt;;&lt;/code&gt; separated):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$cLines$&lt;/code&gt;: &lt;code&gt;productId/quantity&lt;/code&gt; per line, this is what gets saved&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$cNets$&lt;/code&gt;: the net amount of each line in cents, for the running total&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$cTexts$&lt;/code&gt;: the display text, one line per entry
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variables
    numeric cCust, cPid
    string cLines, cTexts, cNets
endvariables
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing touches the database until the user saves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Price preview while typing
&lt;/h2&gt;

&lt;p&gt;The quantity field has a &lt;code&gt;loseFocus&lt;/code&gt; trigger. It normalizes the input through a service (decimal comma, at most three decimals) and refreshes the price label:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="k"&gt;entry&lt;/span&gt; &lt;span class="no"&gt;LEAVE_QTY&lt;/span&gt;
&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="n"&gt;numeric&lt;/span&gt; &lt;span class="n"&gt;vMilli&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;F_QTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;@ &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;activate&lt;/span&gt; &lt;span class="s2"&gt;"SALESIN_SVC"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PARSE_QTY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;F_QTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;@&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vMilli&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="no"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;@ &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="no"&gt;F_QTY&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;@ &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SHOW_PRICE&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The price itself comes from a service operation that asks the existing pricing service for the customer's price and discount, and computes the line net in SQLite to get the rounding right:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    call GET_TEXT("SELECT CAST(ROUND(%%(vQty) * %%(vPrice) / 1000.0 * (10000 - %%(vBp)) / 10000.0) AS INTEGER) AS N", vNet)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Quantities are kept in thousandths, prices in cents, discounts in basis points, so all inputs are integers. For 10,5 pieces at 8,00 with 5 % discount the form shows &lt;code&gt;line net 79,80&lt;/code&gt; before the line is added.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding and removing lines
&lt;/h2&gt;

&lt;p&gt;Adding a line appends to the lists with &lt;code&gt;putitem&lt;/code&gt; and index &lt;code&gt;-1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    vL = $cLines$
    putitem vL, -1, $concat($cPid$, "/", vQty)
    $cLines$ = vL
    vL = $cNets$
    putitem vL, -1, vNet
    $cNets$ = vL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removing the last line uses &lt;code&gt;$itemcount&lt;/code&gt; and &lt;code&gt;delitem&lt;/code&gt; on both lists. The display text is a multi-line string, so its last line is cut separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry DO_REMOVE
variables
    string vL, vT
    numeric vN
endvariables
    if ($cLines$ = "")
        INFO.@ = "There is no line to remove."
        return 0
    endif
    vL = $cLines$
    vN = $itemcount(vL)
    delitem vL, vN
    $cLines$ = vL
    vL = $cNets$
    delitem vL, vN
    $cNets$ = vL
    vT = $cTexts$
    if (vN = 1)
        vT = ""
    else
        call CUT_LAST(vT)
    endif
    $cTexts$ = vT
    call SHOW_LINES
    INFO.@ = "Last line removed."
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The running total is a &lt;code&gt;forlist&lt;/code&gt; over the net list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    forlist vNet in $cNets$
        vTotal = vTotal + vNet
        vN = vN + 1
    endfor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  One save, all or nothing
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Ctrl+A&lt;/code&gt; fires the form's &lt;code&gt;accept&lt;/code&gt; trigger. It calls the save entry and returns &lt;code&gt;-1&lt;/code&gt;, so the form stays open for the next document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trigger accept
    call DO_SAVE
    return -1
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The save passes the whole line list to one service operation. That operation only uses the existing sales document service (&lt;code&gt;CREATE_DOC&lt;/code&gt;, &lt;code&gt;ADD_PRODUCT_LINE&lt;/code&gt;, &lt;code&gt;RECALC&lt;/code&gt;), so rights checks, number ranges and tax calculation stay in one place. If any line fails, it rolls back:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;    &lt;span class="n"&gt;forlist&lt;/span&gt; &lt;span class="n"&gt;vItem&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pLines&lt;/span&gt;
        &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A line could not be read (%%(vItem))."&lt;/span&gt;
            &lt;span class="n"&gt;rollback&lt;/span&gt;
            &lt;span class="n"&gt;pDocId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
            &lt;span class="n"&gt;pDocNo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;vPid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vItem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;vLen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vItem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;vPos&lt;/span&gt;
        &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;vQty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vItem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;vPos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;vLen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;activate&lt;/span&gt; &lt;span class="s2"&gt;"SALESDOC_SVC"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ADD_PRODUCT_LINE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pDocId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vPid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vQty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vLineId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;rollback&lt;/span&gt;
            &lt;span class="n"&gt;pDocId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
            &lt;span class="n"&gt;pDocNo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="n"&gt;vN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vN&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endfor&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The form commits only after the operation returned successfully:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;    &lt;span class="n"&gt;activate&lt;/span&gt; &lt;span class="s2"&gt;"SALESIN_SVC"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QUICK_DOC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;F_TYPE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;@&lt;span class="p"&gt;,&lt;/span&gt; $&lt;span class="n"&gt;cCust&lt;/span&gt;$&lt;span class="p"&gt;,&lt;/span&gt; $&lt;span class="n"&gt;cLines&lt;/span&gt;$&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vDocId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vDocNo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;rollback&lt;/span&gt;
        &lt;span class="no"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;@ &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;commit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Do not lose lines on close
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;quit&lt;/code&gt; trigger asks before discarding unsaved lines. Returning &lt;code&gt;-1&lt;/code&gt; keeps the form open:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight igorpro"&gt;&lt;code&gt;&lt;span class="n"&gt;trigger&lt;/span&gt; &lt;span class="n"&gt;quit&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$cLines&lt;/span&gt;$ &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;askmess&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt; &lt;span class="s2"&gt;"The lines have not been saved as a document. Close anyway?~Close"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Yes,No"&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$status&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  One lesson from the tests
&lt;/h2&gt;

&lt;p&gt;The form turns &lt;code&gt;Q&lt;/code&gt; and &lt;code&gt;O&lt;/code&gt; into &lt;code&gt;QUOTE&lt;/code&gt; and &lt;code&gt;ORDER&lt;/code&gt; in a &lt;code&gt;loseFocus&lt;/code&gt; trigger. The automated test calls the service directly with &lt;code&gt;"q"&lt;/code&gt;, and the first run failed with "The document type must be QUOTE or ORDER." A field trigger only helps users of that form. The service now accepts the short forms too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight abap"&gt;&lt;code&gt;    &lt;span class="n"&gt;vType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;uppercase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;TRIM_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Q"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"QUOTE"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"O"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ORDER"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a rule matters, put it in the service; the trigger is a convenience on top.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Item lists in component variables are a light way to collect lines before anything is written.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;putitem&lt;/code&gt; with &lt;code&gt;-1&lt;/code&gt; appends, &lt;code&gt;$itemcount&lt;/code&gt; plus &lt;code&gt;delitem&lt;/code&gt; removes the last item.&lt;/li&gt;
&lt;li&gt;Compute money in integers (cents, thousandths, basis points) and round once, in SQL.&lt;/li&gt;
&lt;li&gt;Write the whole document in one service call and roll back on the first error.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;accept&lt;/code&gt; and &lt;code&gt;quit&lt;/code&gt; triggers with &lt;code&gt;return -1&lt;/code&gt; turn Ctrl+A into "save and continue" and protect unsaved input.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>sqlite</category>
      <category>forms</category>
    </item>
    <item>
      <title>Two $concat pitfalls in Uniface ProcScript - arithmetic arguments and the argument count</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:27:36 +0000</pubDate>
      <link>https://dev.to/f345345dfg/two-concat-pitfalls-in-uniface-procscript-arithmetic-arguments-and-the-argument-count-51md</link>
      <guid>https://dev.to/f345345dfg/two-concat-pitfalls-in-uniface-procscript-arithmetic-arguments-and-the-argument-count-51md</guid>
      <description>&lt;p&gt;&lt;code&gt;$concat&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. No arithmetic inside the argument list
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    pLabel = $concat(pLabel, ", discount ", vBp / 100, " %")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The compiler reported error 1000 on this line. The fix is a numeric variable that holds the result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vToday&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vSource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vPriceText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vSrcText&lt;/span&gt;
    &lt;span class="n"&gt;numeric&lt;/span&gt; &lt;span class="n"&gt;vPrice&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vBp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vQty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vPct&lt;/span&gt;
    &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;vOk&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vBp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vPct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vBp&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
        &lt;span class="n"&gt;pLabel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pLabel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;", discount "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vPct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;" %"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;pLabel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pLabel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;", line net "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h2&gt;
  
  
  2. Too many arguments
&lt;/h2&gt;

&lt;p&gt;The second limit showed up in the quick customer entry form of the same app: a &lt;code&gt;$concat&lt;/code&gt; 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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    vLine = PROD_NAME.@
    vLine = $concat(vLine, " | quantity ", vQty, " | net ", vNetText)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first assignment can itself be a &lt;code&gt;$concat&lt;/code&gt; with up to five arguments, and the second appends the rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  A check before the compiler
&lt;/h2&gt;

&lt;p&gt;Compiling a form in the IDE takes a few clicks, so I generate the ProcScript from Python and check the &lt;code&gt;$concat&lt;/code&gt; 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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finditer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;'\$concat\('&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'"'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'"'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'('&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;')'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;','&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h2&gt;
  
  
  Related: &lt;code&gt;%%(...)&lt;/code&gt; substitution is often simpler
&lt;/h2&gt;

&lt;p&gt;For messages with many parts, ProcScript string substitution avoids &lt;code&gt;$concat&lt;/code&gt; entirely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    INFO.@ = "Saved as %%(vDocNo). It can be edited further in the sales menu."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside &lt;code&gt;%%(...)&lt;/code&gt; you also pass a variable, not an expression, so the rule from section 1 applies here as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

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

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>python</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Uniface 10 field triggers - leaveField compiles, but loseFocus is what runs</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:25:34 +0000</pubDate>
      <link>https://dev.to/f345345dfg/uniface-10-field-triggers-leavefield-compiles-but-losefocus-is-what-runs-gep</link>
      <guid>https://dev.to/f345345dfg/uniface-10-field-triggers-leavefield-compiles-but-losefocus-is-what-runs-gep</guid>
      <description>&lt;p&gt;A customer app built in Uniface 10 got a quick entry form: while the user moves from field to field, the form tidies names, checks the e-mail address, fills in the city from the postal code and lists similar customers. All of that runs in field triggers. The first version did nothing at all, and the compiler did not complain.&lt;/p&gt;

&lt;p&gt;Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trigger that never ran
&lt;/h2&gt;

&lt;p&gt;The field script of the postal code field looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trigger leaveField
    call LEAVE_POSTAL
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compile: 0 errors, the usual warning about the non-modeled entity. Run: nothing. The buttons on the same form, whose field scripts use &lt;code&gt;trigger detail&lt;/code&gt;, worked fine.&lt;/p&gt;

&lt;p&gt;The reason is the trigger name. Uniface 10 renamed the interactive field triggers. The one that fires when the cursor leaves a field is now &lt;code&gt;loseFocus&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Uniface 9&lt;/th&gt;
&lt;th&gt;Uniface 10&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Field Gets Focus&lt;/td&gt;
&lt;td&gt;&lt;code&gt;getFocus&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Field Loses Focus&lt;/td&gt;
&lt;td&gt;&lt;code&gt;loseFocus&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validate&lt;/td&gt;
&lt;td&gt;&lt;code&gt;validate&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Detail&lt;/td&gt;
&lt;td&gt;&lt;code&gt;detail&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Value Changed&lt;/td&gt;
&lt;td&gt;&lt;code&gt;valueChanged&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(From the Uniface 10 documentation, "Changes in Triggers".)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;leaveField&lt;/code&gt; is not one of them, yet the compiler accepted it. In my setup it compiled without an error or a warning, the name even shows up in the compiled form, and it is simply never called. If a field trigger seems dead, check its name first.&lt;/p&gt;

&lt;p&gt;The working version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trigger loseFocus
    call LEAVE_POSTAL
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the entry it calls, from the form's component script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry LEAVE_POSTAL
variables
    string vMsg, vCity
    numeric vN
endvariables
    if (F_POSTAL.QCU_DMY = "")
        return 0
    endif
    activate "ENTRY_SVC".CHECK_POSTAL(F_POSTAL.QCU_DMY, F_COUNTRY.QCU_DMY, vMsg)
    if ($status = 1)
        INFO.QCU_DMY = vMsg
        return 0
    endif
    activate "ENTRY_SVC".CITY_FOR_POSTAL(F_POSTAL.QCU_DMY, F_COUNTRY.QCU_DMY, vCity, vN)
    if (vCity = "")
        INFO.QCU_DMY = "No address with this postal code yet."
        return 0
    endif
    if (F_CITY.QCU_DMY = "")
        F_CITY.QCU_DMY = vCity
        if (vN &amp;gt; 1)
            INFO.QCU_DMY = "City filled in; %%(vN) different cities are known for this postal code."
        else
            INFO.QCU_DMY = "City filled in from existing addresses."
        endif
    else
        if ($lowercase(F_CITY.QCU_DMY) != $lowercase(vCity))
            INFO.QCU_DMY = "Existing addresses with this postal code use the city %%(vCity)."
        endif
    endif
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;loseFocus&lt;/code&gt; runs whether or not the value was changed, so the entry returns early when the field is empty and does not overwrite a city the user typed (it only mentions a different one).&lt;/p&gt;

&lt;h2&gt;
  
  
  Double-click on an edit box
&lt;/h2&gt;

&lt;p&gt;The tag field should show suggestions on double-click, so it got &lt;code&gt;trigger detail&lt;/code&gt;. That did not run either. In an edit box, a double-click selects a word by default. The widget property Double-Click (&lt;code&gt;DblClk&lt;/code&gt;) decides; with the value &lt;code&gt;Detail&lt;/code&gt; it fires the detail trigger. It can be set at runtime, for example in &lt;code&gt;exec&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $fieldproperties(F_TAG.QCU_DMY) = "DblClk=Detail"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The keyboard function for &lt;code&gt;^DETAIL&lt;/code&gt; fires the trigger regardless of this setting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the field script lives in an XML export
&lt;/h2&gt;

&lt;p&gt;The form is generated and imported as XML. A field trigger is not part of the component script; it sits in the &lt;code&gt;USCRIPT&lt;/code&gt; element of that field's occurrence, next to the widget type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ULABEL"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;F_POSTAL&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
...
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"USCRIPT"&lt;/span&gt; &lt;span class="na"&gt;xml:space&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'preserve'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;trigger loseFocus
    call LEAVE_POSTAL
    return 0
end
&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;DAT&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"FRM_WIDGETTYPE"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;EDITBOX&lt;span class="nt"&gt;&amp;lt;/DAT&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep that in mind when you compare repository sources with files: a tool that only looks at the component script will not see field triggers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two more observations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Field triggers run inside the form, so a value assigned to the field in the trigger is visible immediately.&lt;/li&gt;
&lt;li&gt;In these generated forms the Tab key also stops on label fields. Clicking into the next field fires &lt;code&gt;loseFocus&lt;/code&gt; just as reliably.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use the Uniface 10 trigger names: &lt;code&gt;loseFocus&lt;/code&gt;, &lt;code&gt;getFocus&lt;/code&gt;, &lt;code&gt;validate&lt;/code&gt;, &lt;code&gt;detail&lt;/code&gt;, &lt;code&gt;valueChanged&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;An unknown trigger name compiles quietly. Test that each trigger runs at least once.&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;DblClk=Detail&lt;/code&gt; on edit boxes that should react to a double-click.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>desktop</category>
      <category>triggers</category>
    </item>
    <item>
      <title>Date shortcuts like +7, +2w and mon with SQLite date modifiers in a Uniface service</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:23:15 +0000</pubDate>
      <link>https://dev.to/f345345dfg/date-shortcuts-like-7-2w-and-mon-with-sqlite-date-modifiers-in-a-uniface-service-41i8</link>
      <guid>https://dev.to/f345345dfg/date-shortcuts-like-7-2w-and-mon-with-sqlite-date-modifiers-in-a-uniface-service-41i8</guid>
      <description>&lt;p&gt;A follow-up form in a Uniface customer app has a due date field. Typing &lt;code&gt;30.11.2026&lt;/code&gt; works, but most follow-ups are "in a week" or "next Monday". So the field now also accepts shortcuts and shows what they mean:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Result shown&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;today&lt;/code&gt;, &lt;code&gt;t&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;today&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;tomorrow&lt;/code&gt;, &lt;code&gt;tm&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;tomorrow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;+7&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;in 7 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;+2w&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;in 14 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;mon&lt;/code&gt; ... &lt;code&gt;sun&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;the next such weekday, never today&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;31.12.2026&lt;/code&gt;, &lt;code&gt;2026-12-31&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;that date&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The label also says if the day is on a weekend or a holiday from the app's holiday table, for example &lt;code&gt;Thu, 19.11.2026 (in 3 days, Company holiday)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026, SQLite through the SLE driver (SQLite 3.50.2).&lt;/p&gt;

&lt;h2&gt;
  
  
  SQLite does the calendar
&lt;/h2&gt;

&lt;p&gt;SQLite's &lt;code&gt;date()&lt;/code&gt; takes modifiers that cover everything except the parsing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="kt"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'now'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'localtime'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'+7 days'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="kt"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'now'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'localtime'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'+1 days'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'weekday 1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;weekday N&lt;/code&gt; moves forward to the next day with that weekday number (0 = Sunday), or stays if it already is one. Starting from tomorrow (&lt;code&gt;+1 days&lt;/code&gt;) makes "mon" on a Monday mean next week's Monday.&lt;/p&gt;

&lt;h2&gt;
  
  
  The operation
&lt;/h2&gt;

&lt;p&gt;The service operation turns the input into one modifier string and asks SQLite for the date, then builds the label in a second query. &lt;code&gt;PARSE_DAY&lt;/code&gt; is the app's existing date parser for typed dates; it rejects impossible dates such as 30.02.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="n"&gt;public&lt;/span&gt; &lt;span class="n"&gt;operation&lt;/span&gt; &lt;span class="no"&gt;DAY_INFO&lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pText&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pIso&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pLabel&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
&lt;span class="n"&gt;endparams&lt;/span&gt;
&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vMod&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vOk&lt;/span&gt;
    &lt;span class="n"&gt;numeric&lt;/span&gt; &lt;span class="n"&gt;vPos&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
    &lt;span class="n"&gt;pIso&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;pLabel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;vT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;lowercase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;TRIM_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"today"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;vT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"t"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"+0 days"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tomorrow"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;vT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"tm"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"+1 days"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;vT&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"+"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vNum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vT&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vNum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;vNum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vNum&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;vLen&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SQL_ESCAPE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vNum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT CASE WHEN '%%(vNum)' GLOB '[0-9]*' AND NOT '%%(vNum)' GLOB '*[^0-9]*' AND CAST('%%(vNum)' AS INTEGER) &amp;lt;= 3650 THEN 'Y' ELSE 'N' END AS OK"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vOk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vOk&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"Y"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;pError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Use +N for N days or +Nw for N weeks, for example +7 or +2w."&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT '+' || (CAST('%%(vNum)' AS INTEGER) * 7) || ' days' AS M"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vMod&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"+%%(vNum) days"&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;",sun,mon,tue,wed,thu,fri,sat,"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;",%%(vT),"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; $&lt;span class="nf"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vPos&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
            &lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"+1 days', 'weekday %%(vPos)"&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vMod&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT date('now', 'localtime', '%%(vMod)') AS D"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pIso&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;PARSE_DAY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pText&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pIso&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT substr('SunMonTueWedThuFriSat', CAST(strftime('%w', d) AS INTEGER) * 3 + 1, 3) || ', ' || strftime('%d.%m.%Y', d) || ' (' || CASE WHEN n = 0 THEN 'today' WHEN n = 1 THEN 'tomorrow' WHEN n = -1 THEN 'yesterday' WHEN n &amp;gt; 1 THEN 'in ' || n || ' days' ELSE (0 - n) || ' days ago' END || CASE WHEN strftime('%w', d) IN ('0', '6') THEN ', weekend' ELSE '' END || COALESCE((SELECT ', ' || h.HOLIDAY_NAME FROM APP_HOLIDAY h WHERE h.HOLIDAY_DATE = d), '') || ')' AS LBL FROM (SELECT '%%(pIso)' AS d, CAST(julianday('%%(pIso)') - julianday(date('now', 'localtime')) AS INTEGER) AS n)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pLabel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;+Nw&lt;/code&gt; is turned into days by SQLite as well (&lt;code&gt;CAST(... AS INTEGER) * 7&lt;/code&gt;), so the value is checked to be digits only and at most 3650 before it is used.&lt;/li&gt;
&lt;li&gt;For weekdays, &lt;code&gt;$scan&lt;/code&gt; finds the position of &lt;code&gt;,mon,&lt;/code&gt; in &lt;code&gt;,sun,mon,tue,...&lt;/code&gt;; &lt;code&gt;(position - 1) / 4&lt;/code&gt; is the weekday number.&lt;/li&gt;
&lt;li&gt;The weekday modifier is inserted as &lt;code&gt;+1 days', 'weekday 1&lt;/code&gt; inside the quotes, which yields two modifiers in the final statement.&lt;/li&gt;
&lt;li&gt;The label query starts from a one-row subselect with the date &lt;code&gt;d&lt;/code&gt; and the distance in days &lt;code&gt;n&lt;/code&gt;, so the &lt;code&gt;CASE&lt;/code&gt; expressions stay readable. The whole expression has an alias (&lt;code&gt;AS LBL&lt;/code&gt;); with this driver, long unnamed result columns caused trouble earlier in the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In the form
&lt;/h2&gt;

&lt;p&gt;The due date field calls the operation in its &lt;code&gt;loseFocus&lt;/code&gt; trigger, writes the ISO date back into the field and shows the label next to it. Buttons for Today, +1 day, +1 week and Next Monday just put the shortcut into the field and call the same entry, so there is one code path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tests
&lt;/h2&gt;

&lt;p&gt;The automatic test of the module checks every shortcut against SQLite directly, for example that &lt;code&gt;+2w&lt;/code&gt; equals &lt;code&gt;date('now', 'localtime', '+14 days')&lt;/code&gt;, that &lt;code&gt;mon&lt;/code&gt; equals the &lt;code&gt;weekday 1&lt;/code&gt; expression above, that &lt;code&gt;31.12.2026&lt;/code&gt; is labelled &lt;code&gt;Thu, 31.12.2026&lt;/code&gt;, that &lt;code&gt;30.02.2026&lt;/code&gt; and &lt;code&gt;+x&lt;/code&gt; are rejected, and that a test holiday three days ahead shows up in the label. Because the expected values are computed by SQLite at test time, the test does not depend on the day it runs.&lt;/p&gt;

</description>
      <category>uniface</category>
      <category>sqlite</category>
      <category>procscript</category>
      <category>dates</category>
    </item>
    <item>
      <title>Ctrl+A that saves instead of closing - accept and quit triggers in a Uniface form</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:21:10 +0000</pubDate>
      <link>https://dev.to/f345345dfg/ctrla-that-saves-instead-of-closing-accept-and-quit-triggers-in-a-uniface-form-3goh</link>
      <guid>https://dev.to/f345345dfg/ctrla-that-saves-instead-of-closing-accept-and-quit-triggers-in-a-uniface-form-3goh</guid>
      <description>&lt;p&gt;In a Uniface 10 desktop form, Ctrl+A is bound to &lt;code&gt;^ACCEPT&lt;/code&gt;. Users from every other Windows program expect "select all" or nothing at all; what they get is a closed form. While testing a customer app I lost a half-filled form that way more than once. Two component-level triggers fix it, and the same pair adds a "you have unsaved input" question on close.&lt;/p&gt;

&lt;p&gt;Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  accept and quit
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;trigger accept&lt;/code&gt; fires on &lt;code&gt;^ACCEPT&lt;/code&gt; (Ctrl+A) or &lt;code&gt;activate "FORM".accept()&lt;/code&gt;. If it completes successfully, the form ends.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trigger quit&lt;/code&gt; fires on &lt;code&gt;^QUIT&lt;/code&gt;, which in this app is what the Close button sends, and when the window is closed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In both, &lt;code&gt;return -1&lt;/code&gt; keeps the form open. That is all it takes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight q"&gt;&lt;code&gt;&lt;span class="n"&gt;operation&lt;/span&gt; &lt;span class="n"&gt;exec&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SET_LABELS&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SET_RIGHTS&lt;/span&gt;
    &lt;span class="nv"&gt;$fieldproperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;F_TAG&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;QCU_DMY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"DblClk=Detail"&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;DO_CLEAR&lt;/span&gt;
    &lt;span class="n"&gt;edit&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;trigger&lt;/span&gt; &lt;span class="n"&gt;accept&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;DO_SAVE&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="n"&gt;trigger&lt;/span&gt; &lt;span class="n"&gt;quit&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;CHECK_UNSAVED&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$status&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ctrl+A now saves the new customer and the form stays open for the next one. &lt;code&gt;DO_SAVE&lt;/code&gt; is the same entry the Save button calls, so there is only one code path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unsaved input without a database entity
&lt;/h2&gt;

&lt;p&gt;Forms that edit database occurrences can ask Uniface whether something was modified (&lt;code&gt;$instancedbmod&lt;/code&gt;). This quick entry form works with a non-database entity: the user types, a service writes the data. So the form keeps its own snapshot of the field values in a component variable (&lt;code&gt;cSnap&lt;/code&gt;, declared as &lt;code&gt;string cSnap&lt;/code&gt;) and compares it on close:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry GET_SNAP
params
    string pSnap : OUT
endparams
    pSnap = $concat(F_LAST.QCU_DMY, "|", F_FIRST.QCU_DMY, "|")
    pSnap = $concat(pSnap, F_EMAIL.QCU_DMY, "|")
    pSnap = $concat(pSnap, F_PHONE.QCU_DMY, "|", F_STREET.QCU_DMY, "|")
    pSnap = $concat(pSnap, F_POSTAL.QCU_DMY, "|", F_CITY.QCU_DMY, "|")
    pSnap = $concat(pSnap, F_TAG.QCU_DMY)
    return 0
end

entry CHECK_UNSAVED
variables
    string vSnap
endvariables
    call GET_SNAP(vSnap)
    if (vSnap != $cSnap$)
        askmess/question "The new customer has not been saved. Close anyway?~Close", "Yes,No"
        if ($status != 1)
            return -1
        endif
    endif
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The snapshot is taken whenever the form is clean, after a save or a clear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry CLEAR_FIELDS
variables
    string vSnap
endvariables
    F_LAST.QCU_DMY = ""
    F_FIRST.QCU_DMY = ""
    F_EMAIL.QCU_DMY = ""
    F_PHONE.QCU_DMY = ""
    F_STREET.QCU_DMY = ""
    F_POSTAL.QCU_DMY = ""
    F_CITY.QCU_DMY = ""
    F_TAG.QCU_DMY = ""
    if (F_COUNTRY.QCU_DMY = "")
        F_COUNTRY.QCU_DMY = "DE"
    endif
    $cSim$ = 0
    call GET_SNAP(vSnap)
    $cSnap$ = vSnap
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note the &lt;code&gt;$concat&lt;/code&gt; calls of at most five arguments: with six, the compiler reports error 1000 "Wrong number of arguments".&lt;/p&gt;

&lt;h2&gt;
  
  
  How it behaves
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Typing a customer and pressing Ctrl+A saves it; if similar customers exist, the save asks first.&lt;/li&gt;
&lt;li&gt;Typing and pressing Close asks "The new customer has not been saved. Close anyway?"; No keeps the form and the input.&lt;/li&gt;
&lt;li&gt;Closing an empty or just saved form asks nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same pattern is used in two more forms of the app: in the follow-up form Ctrl+A adds the follow-up, in a data completion form it means "save and next customer".&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;trigger accept&lt;/code&gt; with &lt;code&gt;return -1&lt;/code&gt; turns Ctrl+A into a shortcut of your choice.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trigger quit&lt;/code&gt; with &lt;code&gt;return -1&lt;/code&gt; can stop a close; ask with &lt;code&gt;askmess/question&lt;/code&gt; first.&lt;/li&gt;
&lt;li&gt;For forms without database occurrences, compare a snapshot of the fields.&lt;/li&gt;
&lt;li&gt;Tell users about the shortcut on the form itself; this one says "Ctrl+A saves." next to the fields.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>desktop</category>
      <category>ux</category>
    </item>
    <item>
      <title>A Uniface test service that just stopped - four things I learned debugging it</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:19:28 +0000</pubDate>
      <link>https://dev.to/f345345dfg/a-uniface-test-service-that-just-stopped-four-things-i-learned-debugging-it-2gja</link>
      <guid>https://dev.to/f345345dfg/a-uniface-test-service-that-just-stopped-four-things-i-learned-debugging-it-2gja</guid>
      <description>&lt;p&gt;The new modules of a Uniface customer app come with a test service: it inserts test data, calls every operation, writes &lt;code&gt;PASS&lt;/code&gt;/&lt;code&gt;FAIL&lt;/code&gt; lines with &lt;code&gt;putmess&lt;/code&gt; and rolls everything back. The IDE runs it with &lt;em&gt;Compile &amp;amp; Test&lt;/em&gt;. This time the run never finished. The log showed two lines and then nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Feature 38 tests started
PASS: SETUP inserts the test data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No error message, no dialog, and the database file had an open journal. Here is what the hunt taught me.&lt;/p&gt;

&lt;p&gt;Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026, SQLite through the SLE driver (SQLite 3.50.2).&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The last log line is not where the test stopped
&lt;/h2&gt;

&lt;p&gt;The obvious reading was: the test hangs in the block right after the setup. That was wrong. The message log is written in chunks. In a later run the log showed only the first line for over a minute while the test had already passed much further.&lt;/p&gt;

&lt;p&gt;For position tracking I switched to a file that is overwritten at every step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    lfiledump "TRACE TEST_EINV 9", "C:\Projects\Customers\export\test\trace38.txt"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;lfiledump&lt;/code&gt; writes immediately, so the file always holds the last step that was reached.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. lfiledump sets $status
&lt;/h2&gt;

&lt;p&gt;My first traced run reported 56 failures out of 60. Every check printed a status between 17 and 20. The trace line sat between the call and the status check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;    &lt;span class="n"&gt;activate&lt;/span&gt; &lt;span class="s2"&gt;"EINV_SVC"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SELLER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vCount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;lfiledump&lt;/span&gt; &lt;span class="s2"&gt;"TRACE TEST_EINV 12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"C:\Projects\Customers\export\test\trace38.txt"&lt;/span&gt;
    &lt;span class="n"&gt;vS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="n"&gt;status&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;lfiledump&lt;/code&gt; returns the number of bytes written in &lt;code&gt;$status&lt;/code&gt;; "TRACE TEST_EINV 12" has 18 characters. Trace lines belong after &lt;code&gt;vS = $status&lt;/code&gt;, or in a version of the code that is thrown away afterwards, which is what I did.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. A long SQL column without an alias crashed the process
&lt;/h2&gt;

&lt;p&gt;The trace file pinned the problem to one statement in the IBAN check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;CASE&lt;/span&gt; &lt;span class="s1"&gt;'DE'&lt;/span&gt; &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="s1"&gt;'DE'&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt; &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="s1"&gt;'AT'&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="k"&gt;ELSE&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;END&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The query is fine in the sqlite3 shell. In the test run the process ended a few minutes later without any message in the log; the IDE only showed a transcript window with a fatal message about a missing &lt;code&gt;$resources_output&lt;/code&gt; setting.&lt;/p&gt;

&lt;p&gt;What made this statement special: the result column has no name, so SQLite uses the whole expression (372 characters) as the column name. Nothing else in the project returned an unnamed column longer than 250 characters. After adding an alias the test ran through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight abap"&gt;&lt;code&gt;    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT CASE '%%(vCountry)' WHEN 'DE' THEN 22 WHEN 'AT' THEN 20 WHEN 'CH' THEN 21 WHEN 'FR' THEN 27 WHEN 'NL' THEN 18 WHEN 'BE' THEN 16 WHEN 'IT' THEN 27 WHEN 'ES' THEN 24 WHEN 'LU' THEN 20 WHEN 'DK' THEN 18 WHEN 'PL' THEN 28 WHEN 'CZ' THEN 24 WHEN 'GB' THEN 22 WHEN 'IE' THEN 22 WHEN 'SE' THEN 24 WHEN 'FI' THEN 18 WHEN 'NO' THEN 15 WHEN 'PT' THEN 25 WHEN 'LI' THEN 21 ELSE 0 END AS L"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have not dug into the driver to find an exact limit, so treat this as an observation from one setup, not a documented rule. The habit costs nothing: every computed column gets a short alias. I added aliases to the three other long expressions in the same service at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Trailing spaces disappear on the way to ProcScript
&lt;/h2&gt;

&lt;p&gt;With the crash gone, six checks of the data tidy module failed. The module finds values like &lt;code&gt;"Tom  "&lt;/code&gt; and stores the tidied value. To avoid overwriting a value someone changed in the meantime, the update compared the field with the old value it had read:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="no"&gt;CUSTOMER_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3800005&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="no"&gt;FIRST_NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Tom'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database holds &lt;code&gt;'Tom  '&lt;/code&gt;. The trailing spaces were lost when the row came back through &lt;code&gt;sql/data&lt;/code&gt; and &lt;code&gt;getitem&lt;/code&gt;, so the update matched no row. The history entry was written, the data was not changed. The fix compares trimmed values on both sides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;sql&lt;/span&gt; &lt;span class="s2"&gt;"UPDATE %%(vTable) SET %%(vField) = %%(vNewLit)%%(vExtra) WHERE %%(vIdCol) = %%(vRowId) AND TRIM(%%(vField)) = TRIM(%%(vOldLit))"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CUSTOMERS"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same effect made the preview useless: it said &lt;code&gt;FIRST_NAME: [Tom] to [Tom]&lt;/code&gt;. The preview query now returns two extra columns for display only, with spaces made visible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;REPLACE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;FIRST_NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so the user sees &lt;code&gt;[Tom__] to [Tom]&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small helper for stuck runs
&lt;/h2&gt;

&lt;p&gt;A crashed or stuck test process has no window. To end it without the Task Manager, the project folder now has a script that stops only IDE processes started with &lt;code&gt;/tst&lt;/code&gt; and leaves the IDE itself alone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Join&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$PSScriptRoot&lt;/span&gt; &lt;span class="s1"&gt;'kill_uniface_tests.log'&lt;/span&gt;
&lt;span class="nv"&gt;$all&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;CimInstance&lt;/span&gt; &lt;span class="nc"&gt;Win32_Process&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CommandLine&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="s1"&gt;'Uniface'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;$tests&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$all&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CommandLine&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="s1"&gt;' /tst '&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;$line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Date&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Format&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' all='&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$all&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;ForEach&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;':'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProcessId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt; &lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' tests='&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$tests&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;ForEach&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProcessId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt; &lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;$tests&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;ForEach&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Stop&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;Process&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Id&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ProcessId&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Force&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;Add&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Content&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt; &lt;span class="nv"&gt;$log&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Value&lt;/span&gt; &lt;span class="nv"&gt;$line&lt;/span&gt;
&lt;span class="nc"&gt;Write&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$line&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Do not trust the last line of a buffered log; write positions to a file.&lt;/li&gt;
&lt;li&gt;Put trace calls where they cannot change &lt;code&gt;$status&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give computed SQL columns an alias.&lt;/li&gt;
&lt;li&gt;Expect trailing spaces to be gone when a value comes back into ProcScript, and compare with &lt;code&gt;TRIM&lt;/code&gt; where it matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the four fixes the test service reports 60 tests, 0 failures, and the database is unchanged after the run.&lt;/p&gt;

</description>
      <category>uniface</category>
      <category>sqlite</category>
      <category>debugging</category>
      <category>testing</category>
    </item>
    <item>
      <title>Checking IBANs in Uniface ProcScript - mod 97 without big numbers</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:18:06 +0000</pubDate>
      <link>https://dev.to/f345345dfg/checking-ibans-in-uniface-procscript-mod-97-without-big-numbers-568f</link>
      <guid>https://dev.to/f345345dfg/checking-ibans-in-uniface-procscript-mod-97-without-big-numbers-568f</guid>
      <description>&lt;p&gt;A customer app built in Uniface 10 creates e-invoices (XRechnung). An e-invoice carries the seller's bank account, so the form that stores the seller data should refuse an IBAN with a typo before it ends up in hundreds of invoices.&lt;/p&gt;

&lt;p&gt;Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2).&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule
&lt;/h2&gt;

&lt;p&gt;An IBAN such as &lt;code&gt;DE89 3704 0044 0532 0130 00&lt;/code&gt; is checked like this (ISO 13616 / ISO 7064 MOD 97-10):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remove the spaces, upper case.&lt;/li&gt;
&lt;li&gt;Move the first four characters (country code and check digits) to the end.&lt;/li&gt;
&lt;li&gt;Replace every letter by two digits: A = 10, B = 11, ..., Z = 35.&lt;/li&gt;
&lt;li&gt;Read the result as one integer. The IBAN is valid if the remainder of a division by 97 is 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step 4 is the problem: the number has 30 digits and more, far beyond what a numeric variable holds exactly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remainder one digit at a time
&lt;/h2&gt;

&lt;p&gt;You do not need the whole number. If &lt;code&gt;m&lt;/code&gt; is the remainder of what you have read so far, appending the next digit &lt;code&gt;d&lt;/code&gt; gives the remainder &lt;code&gt;(m * 10 + d) mod 97&lt;/code&gt;. A letter stands for two digits, so it shifts by 100 instead of 10. The running value never grows beyond 96 * 100 + 35, and ProcScript can reduce it with a short subtraction loop instead of a modulo function.&lt;/p&gt;

&lt;h2&gt;
  
  
  The entry
&lt;/h2&gt;

&lt;p&gt;This is the complete local entry of the service. Two small SQL calls do the parts SQL is good at (normalising, a pattern check, a length table); the checksum is plain ProcScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="k"&gt;entry&lt;/span&gt; &lt;span class="no"&gt;IBAN_RESULT&lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pIban&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pNorm&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pResult&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
&lt;span class="n"&gt;endparams&lt;/span&gt;
&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vCountry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vSql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vEsc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vC&lt;/span&gt;
    &lt;span class="n"&gt;numeric&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vWant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vRest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vD&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
    &lt;span class="n"&gt;vEsc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pIban&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SQL_ESCAPE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vEsc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT replace(upper('%%(vEsc)'), ' ', '')"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pNorm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;
    &lt;span class="n"&gt;pResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"OK"&lt;/span&gt;
    &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;vEsc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;SQL_ESCAPE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vEsc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT CASE WHEN '%%(vEsc)' GLOB '[A-Z][A-Z][0-9][0-9]*' AND NOT '%%(vEsc)' GLOB '*[^0-9A-Z]*' THEN 'Y' ELSE 'N' END"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vR&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"Y"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;pResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"WRONG_CHARACTERS"&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;vCountry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT CASE '%%(vCountry)' WHEN 'DE' THEN 22 WHEN 'AT' THEN 20 WHEN 'CH' THEN 21 WHEN 'FR' THEN 27 WHEN 'NL' THEN 18 WHEN 'BE' THEN 16 WHEN 'IT' THEN 27 WHEN 'ES' THEN 24 WHEN 'LU' THEN 20 WHEN 'DK' THEN 18 WHEN 'PL' THEN 28 WHEN 'CZ' THEN 24 WHEN 'GB' THEN 22 WHEN 'IE' THEN 22 WHEN 'SE' THEN 24 WHEN 'FI' THEN 18 WHEN 'NO' THEN 15 WHEN 'PT' THEN 25 WHEN 'LI' THEN 21 ELSE 0 END AS L"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;vWant&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vR&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vWant&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;vWant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;pResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"WRONG_LENGTH"&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;vRest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
    &lt;span class="n"&gt;vX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;vRest&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vNorm&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;vLen&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;vC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vX&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;vI&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;vD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vC&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vD&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;vD&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;
            &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;vD&lt;/span&gt;
        &lt;span class="n"&gt;endif&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;97&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;97&lt;/span&gt;
        &lt;span class="n"&gt;endwhile&lt;/span&gt;
        &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vI&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endwhile&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vM&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;pResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"WRONG_CHECKSUM"&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes on the code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;vNorm[5:vRest]&lt;/code&gt; is a substring from position 5 with length &lt;code&gt;vRest&lt;/code&gt;; &lt;code&gt;vNorm[1:4]&lt;/code&gt; are the first four characters. Together they are step 2.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$scan&lt;/code&gt; returns the position of the character in the list &lt;code&gt;0-9A-Z&lt;/code&gt;, so position minus 1 is exactly the value from step 3: digits 0 to 9, letters 10 to 35.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;GLOB&lt;/code&gt; check runs first, so the loop only ever sees digits and capital letters.&lt;/li&gt;
&lt;li&gt;The length table covers the countries this app deals with; for any other country only the general limit of 15 to 34 characters applies.&lt;/li&gt;
&lt;li&gt;The length &lt;code&gt;CASE&lt;/code&gt; has an alias (&lt;code&gt;AS L&lt;/code&gt;). The companion article on debugging explains why that matters with this driver.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;GET_TEXT&lt;/code&gt; is a small helper that runs a query and returns the first column of the first row:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight openedge"&gt;&lt;code&gt;&lt;span class="k"&gt;entry&lt;/span&gt; &lt;span class="no"&gt;GET_TEXT&lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pSql&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;pValue&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;OUT&lt;/span&gt;
&lt;span class="n"&gt;endparams&lt;/span&gt;
&lt;span class="n"&gt;variables&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;vData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vRow&lt;/span&gt;
&lt;span class="n"&gt;endvariables&lt;/span&gt;
    &lt;span class="n"&gt;pValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="n"&gt;pSql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"CUSTOMERS"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;$&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;vData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="n"&gt;result&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;endif&lt;/span&gt;
    &lt;span class="n"&gt;getitem&lt;/span&gt; &lt;span class="n"&gt;vRow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;getitem&lt;/span&gt; &lt;span class="n"&gt;pValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vRow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Trying it
&lt;/h2&gt;

&lt;p&gt;Three public example IBANs and one with a changed last digit:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DE89 3704 0044 0532 0130 00&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;OK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GB82 WEST 1234 5698 7654 32&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;OK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DE89 3704 0044 0532 0130 01&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;WRONG_CHECKSUM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AT61 1904 3002 3457 320&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;WRONG_LENGTH&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The same results come from the automatic test service of the module, which also stores a seller IBAN through the form logic and expects the normalised value &lt;code&gt;DE89370400440532013000&lt;/code&gt; in the settings table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not in SQL?
&lt;/h2&gt;

&lt;p&gt;A first version computed the remainder with a recursive CTE and the &lt;code&gt;%&lt;/code&gt; operator in SQLite. It is correct in the sqlite3 shell. When the test process of this module crashed inside this entry, the CTE was the first suspect; the real cause turned out to be another statement (described in the companion article). I kept the ProcScript loop anyway: 30 iterations, no driver involved, easy to step through in the debugger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A valid check digit does not mean the account exists. It catches typos and swapped digits, which is what a data entry form needs.&lt;/li&gt;
&lt;li&gt;The country length table is deliberately short. Extend it from the official IBAN registry if your users enter accounts from more countries.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>procscript</category>
      <category>sqlite</category>
      <category>validation</category>
    </item>
    <item>
      <title>Customer hierarchies with WITH RECURSIVE - finding cycles and group totals in a Uniface service</title>
      <dc:creator>Franz</dc:creator>
      <pubDate>Mon, 16 Nov 2026 16:49:20 +0000</pubDate>
      <link>https://dev.to/f345345dfg/customer-hierarchies-with-with-recursive-finding-cycles-and-group-totals-in-a-uniface-service-1kj</link>
      <guid>https://dev.to/f345345dfg/customer-hierarchies-with-with-recursive-finding-cycles-and-group-totals-in-a-uniface-service-1kj</guid>
      <description>&lt;p&gt;A customer app built in Uniface 10 lets users link customers: a branch belongs to a company, a subsidiary to a group. The table is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CUSTOMER_RELATION (CHILD_ID, PARENT_ID, RELATION_TYPE, ...)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing stops a user from saying "A belongs to B" and later "B belongs to A". Every report that walks up or down the hierarchy then has a problem. This article shows two queries from a check module: one finds such loops, the other adds up revenue per group.&lt;/p&gt;

&lt;p&gt;Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, November 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2).&lt;/p&gt;

&lt;h2&gt;
  
  
  Walking up the tree
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;WITH RECURSIVE&lt;/code&gt; builds a result step by step. The first &lt;code&gt;SELECT&lt;/code&gt; is the start, the second is joined to the rows found so far until it returns nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WITH&lt;/span&gt; &lt;span class="no"&gt;RECURSIVE&lt;/span&gt; &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;START_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;CUR_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;DEPTH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;PATH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="no"&gt;CHILD_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;PARENT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;CHILD_ID&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' &amp;gt; '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="no"&gt;PARENT_ID&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="no"&gt;CUSTOMER_RELATION&lt;/span&gt;
  &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt;
  &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;START_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PARENT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DEPTH&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PATH&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' &amp;gt; '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PARENT_ID&lt;/span&gt;
  &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;walk&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="no"&gt;CUSTOMER_RELATION&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CHILD_ID&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CUR_ID&lt;/span&gt;
  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DEPTH&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CUR_ID&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;START_ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each row says: starting at &lt;code&gt;START_ID&lt;/code&gt;, after &lt;code&gt;DEPTH&lt;/code&gt; steps upwards I am at &lt;code&gt;CUR_ID&lt;/code&gt;. If &lt;code&gt;CUR_ID&lt;/code&gt; ever equals &lt;code&gt;START_ID&lt;/code&gt;, the customer is its own ancestor: a cycle.&lt;/p&gt;

&lt;p&gt;Two conditions stop the recursion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;w.CUR_ID &amp;lt;&amp;gt; w.START_ID&lt;/code&gt;: once the walk is back at the start, it does not continue around the loop again.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w.DEPTH &amp;lt; 20&lt;/code&gt;: a hard limit. Without it, a loop that does not pass through the start customer (A &amp;gt; B &amp;gt; C &amp;gt; B) would run forever.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The operation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public operation CYCLES
params
    string pData : OUT
    numeric pCount : OUT
    string pError : OUT
endparams
    pData = ""
    pCount = 0
    pError = ""
    activate "RIGHTS_SVC".REQUIRE("READ", pError)
    if ($status &amp;lt; 0)
        return -1
    endif
    call READ_ROWS("WITH RECURSIVE walk(START_ID, CUR_ID, DEPTH, PATH) AS (SELECT CHILD_ID, PARENT_ID, 1, CHILD_ID || ' &amp;gt; ' || PARENT_ID FROM CUSTOMER_RELATION UNION ALL SELECT w.START_ID, r.PARENT_ID, w.DEPTH + 1, w.PATH || ' &amp;gt; ' || r.PARENT_ID FROM walk w JOIN CUSTOMER_RELATION r ON r.CHILD_ID = w.CUR_ID WHERE w.DEPTH &amp;lt; 20 AND w.CUR_ID &amp;lt;&amp;gt; w.START_ID) SELECT w.START_ID, c.LAST_NAME || ', ' || c.FIRST_NAME AS NAME, w.DEPTH, w.PATH FROM walk w JOIN CUSTOMER c ON c.CUSTOMER_ID = w.START_ID WHERE w.CUR_ID = w.START_ID ORDER BY 1", pData, pCount, pError)
    if ($status &amp;lt; 0)
        return -1
    endif
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;READ_ROWS&lt;/code&gt; is a small entry in the same service that runs the statement and returns the rows as a Uniface list; &lt;code&gt;RIGHTS_SVC.REQUIRE&lt;/code&gt; checks the role of the logged-in user.&lt;/p&gt;

&lt;p&gt;With two customers pointing at each other:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;START_ID  NAME         DEPTH  PATH
3700007   Ring, Rita   2      3700007 &amp;gt; 3700008 &amp;gt; 3700007
3700008   Loop, Lars   2      3700008 &amp;gt; 3700007 &amp;gt; 3700008
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both members of the loop show up, each with the path that leads back to itself. The form turns this into &lt;code&gt;#3700007 Ring, Rita: back to itself after 2 step(s): 3700007 &amp;gt; 3700008 &amp;gt; 3700007&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Walking down: revenue per group
&lt;/h2&gt;

&lt;p&gt;The second query starts at the top customers (parents that are nobody's child) and walks down. For every top customer it collects all members below, then joins the invoices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public operation GROUP_REVENUE
params
    string pFrom : IN
    string pTo : IN
    string pData : OUT
    numeric pCount : OUT
    string pError : OUT
endparams
variables
    string vFrom, vTo
endvariables
    pData = ""
    pCount = 0
    pError = ""
    activate "RIGHTS_SVC".REQUIRE("READ", pError)
    if ($status &amp;lt; 0)
        return -1
    endif
    call DATE_RANGE(pFrom, pTo, vFrom, vTo, pError)
    if ($status &amp;lt; 0)
        return -1
    endif
    call READ_ROWS("WITH RECURSIVE tree(ROOT_ID, MEMBER_ID, DEPTH) AS (SELECT DISTINCT PARENT_ID, PARENT_ID, 0 FROM CUSTOMER_RELATION WHERE PARENT_ID NOT IN (SELECT CHILD_ID FROM CUSTOMER_RELATION) UNION SELECT t.ROOT_ID, r.CHILD_ID, t.DEPTH + 1 FROM tree t JOIN CUSTOMER_RELATION r ON r.PARENT_ID = t.MEMBER_ID WHERE t.DEPTH &amp;lt; 20), g AS (SELECT DISTINCT ROOT_ID, MEMBER_ID FROM tree WHERE MEMBER_ID IN (SELECT CUSTOMER_ID FROM CUSTOMER)) SELECT g.ROOT_ID, c.LAST_NAME || ', ' || c.FIRST_NAME AS NAME, COUNT(*) - 1 AS MEMBERS, COALESCE(SUM(CASE WHEN g.MEMBER_ID = g.ROOT_ID THEN v.NET END), 0) AS OWN_NET, COALESCE(SUM(v.NET), 0) AS GROUP_NET FROM g JOIN CUSTOMER c ON c.CUSTOMER_ID = g.ROOT_ID LEFT JOIN (SELECT d.CUSTOMER_ID, SUM(d.NET_CENTS) AS NET FROM SALES_DOC d WHERE d.DOC_TYPE = 'INVOICE' AND d.STATUS NOT IN ('DRAFT', 'CANCELLED') AND d.DOC_DATE &amp;gt;= '%%(vFrom)' AND d.DOC_DATE &amp;lt;= '%%(vTo)' GROUP BY d.CUSTOMER_ID) v ON v.CUSTOMER_ID = g.MEMBER_ID GROUP BY 1, 2 ORDER BY 5 DESC, 1", pData, pCount, pError)
    if ($status &amp;lt; 0)
        return -1
    endif
    return 0
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;UNION&lt;/code&gt; instead of &lt;code&gt;UNION ALL&lt;/code&gt; in the recursive part removes duplicate rows. If a customer can be reached on two paths, it would otherwise count twice.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SELECT DISTINCT ROOT_ID, MEMBER_ID&lt;/code&gt; drops the depth, so a member found at two depths is still one member.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MEMBER_ID IN (SELECT CUSTOMER_ID FROM CUSTOMER)&lt;/code&gt; ignores relations to customers that were deleted. A separate check lists those relations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;%%(vFrom)&lt;/code&gt; and &lt;code&gt;%%(vTo)&lt;/code&gt; are the period from the form, checked by the &lt;code&gt;DATE_RANGE&lt;/code&gt; entry and inserted by ProcScript string substitution.&lt;/p&gt;

&lt;p&gt;Result for a small group (parent with a subsidiary and a branch below it):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ROOT_ID  NAME           MEMBERS  OWN_NET  GROUP_NET
3700004  Parent, Paula  2        1000     6000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;The test service inserts the relations and invoices with fixed ids, calls both operations, checks the depth of the cycle and the group total, and rolls back. The same SQL ran beforehand with Python's &lt;code&gt;sqlite3&lt;/code&gt; against a copy of the database with the same rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Recursive queries need two brakes: stop at the start node and stop at a maximum depth.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;UNION&lt;/code&gt; (not &lt;code&gt;UNION ALL&lt;/code&gt;) when the same row can be reached twice.&lt;/li&gt;
&lt;li&gt;Make members distinct before you add up money.&lt;/li&gt;
&lt;li&gt;Keep cycle detection as its own check; the group report then can trust its input.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>uniface</category>
      <category>sqlite</category>
      <category>sql</category>
      <category>procscript</category>
    </item>
  </channel>
</rss>
