In Uniface ProcScript, putitem adds or replaces list items, while getitem copies an item into a variable. This example uses an indexed list, with positions starting at 1.
Build, read, and update a list
Add this operation to your component’s Script section:
public operation LIST_DEMO
variables
string vMonths, vMonth
endvariables
vMonths = ""
; Append three items.
putitem vMonths, -1, "January"
putitem vMonths, -1, "February"
putitem vMonths, -1, "March"
; Read the second item: February.
getitem vMonth, vMonths, 2
putmess vMonth
; Replace the second item, then read it again.
putitem vMonths, 2, "April"
getitem vMonth, vMonths, 2
putmess vMonth
return 0
end
Expected message output:
February
April
Remember these rules
-
putitem vList, -1, valueappends an item. -
putitem vList, 2, valuereplaces the second item. A position beyond the list’s end creates empty intermediate items. -
getitem vValue, vList, 2reads the second item without removing it. Index-1reads the last item. - After
getitem,$status > 0indicates the copied item’s position. If no item was copied,$statusis0and the target is empty. Check the status immediately when handling a potentially missing item.
Use putitem to construct the list instead of typing ordinary semicolons: Uniface uses special list separators.
Top comments (0)