|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > LST. - List Arrays > List-Operations > Smart Package Robot (SPR) List Commands |
MiniRobotLanguage (MRL)
LST.InsPrev
Insert a value before a node in a list
Intention
The LST.InsPrev command inserts a new value before a specified node in a list. This is useful when you need to add data at a specific position in the list without overwriting existing elements.
The command requires the list handle (`$$LST`), the handle of the reference node (`$$NOD`), and the value (`$$VAL`) to insert. The new node will be placed immediately before the reference node.
Syntax
LST.InsPrev|$$LST|$$NOD|$$VAL
Parameter Explanation
$$LST - The list identifier, typically a numeric value or a variable that contains a valid list handle.
$$NOD - The handle of the reference node before which the new value will be inserted.
$$VAL - The value to insert before the reference node.
Example
'***********************************
' LST.InsPrev Sample Script
'***********************************
' Create a new list
LST.New|$$LST
' Add elements to the list
LST.Add|$$LST|World
' Get the first node
LST.First|$$LST|$$NOD
' Insert a value before the first node
LST.InsPrev|$$LST|$$NOD|Hello
' Verify the insertion
LST.First|$$LST|$$NOD
LST.Get|$$LST|$$NOD|$$VAL
DBP. Value of the first node: $$VAL
' Clean up
LST.End|$$LST
ENR.
Remarks
-
Limitations:
- The list must be initialized and contain at least one node.
- The reference node handle must be valid.
See also:
• LST.InsNext - Insert Value After a Node