Replace line in list

Command group Flag affected Reversible Execute on client Platform(s)
List lines YES NO NO All

Syntax

Replace line in list {line-number (values) {default is current line}}

Deprecated Command

This command has been deprecated and is no longer visible in the Code Assistant in the Code Editor (it will not appear when you type the first few characters), although it is still present in Omnis Studio and will continue to function if used in legacy code. You can show this command by disabling the appropriate Command Filter in the Modify menu in the Code Editor.

Description

This command transfers field values from the current record buffer to the corresponding fields in the current list. Alternatively, it is possible to specify a comma-separated list of values enclosed in brackets after the line number. In this case, the values stored in the specified line of the list are set up from the values in the brackets and not from the variables specified when the list was defined.

Replace line in list {LIST.$linecount('abc',,LVAR12+3)}

will store 'abc' into the first column of the final line of the current list, leave the value of the second column unchanged, and load the result of LVAR12+3 into the third column. If too few values are specified, the other columns will be left unchanged; if too many values are specified, the extra values are ignored. Any conversions required between data types are carried out.

If the line number specified in the command line is empty, or if it evaluates to zero, the current line is used. If the list is empty or if the line is beyond the current end of the list, the flag is cleared.

Example

# Replace Harry with Arnold and increment
# the age of everybody in the list by 1
Set current list lMyList
Define list {lName,lAge}
Add line to list {('Fred',10)}
Add line to list {('George',20)}
Add line to list {('Harry',22)}
Add line to list {('William',31)}
Add line to list {('David',62)}
Replace line in list {3 ('Arnold',47)}
For each line in list from 1 to lMyList.$linecount step 1
  Load from list
  Calculate lAge as lAge+1
  Replace line in list {(,lAge)}
End For