|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > LST. - List Arrays > Stack-Operations > Smart Package Robot 's Stack Commands |
MiniRobotLanguage (MRL)
LST.StkPush
Push a Value onto the Stack
Intention
The LST.StkPush command is used to push a value onto the stack of a specified list container. This is useful for managing data in a Last-In-First-Out (LIFO) manner, where the last value pushed onto the stack is the first one to be retrieved.
The stack is a fundamental data structure that allows you to store and retrieve values in a specific order. The LST.StkPush command adds a value to the top of the stack, while the LST.StkPop command retrieves and removes the top value from the stack.
Syntax
LST.StkPush|P1|P2
Parameter Explanation
P1 - The handle of the list container. This is a numeric value or a variable that contains the handle of the list.
P2 - The value to be pushed onto the stack. This can be a numeric value, a string, or a variable containing the value.
Example
'***********************************
' LST.StkPush Sample Script
'***********************************
' Create a new list container
LST.New|$$LST
' Push values onto the stack
LST.StkPush|$$LST|10
LST.StkPush|$$LST|20
LST.StkPush|$$LST|30
' Pop values from the stack
LST.StkPop|$$LST|$$VAL1
LST.StkPop|$$LST|$$VAL2
LST.StkPop|$$LST|$$VAL3
' Display the popped values
DBP.$$VAL1
DBP.$$VAL2
DBP.$$VAL3
' End the script
ENR.
Remarks
-
Limitations:
- The stack size is limited by the available memory.
See also:
• LST.StkPop - Pop a Value from the Stack
• LST.New - Create a New List Container
• LST.End - End a List Container