|
<< 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.StkPop
Pop the Top Value from the Stack
Intention
The LST.StkPop command is used to remove and retrieve the top value from the stack of a specified list container. This is a fundamental operation 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 data structure that allows you to store and retrieve values in a specific order. The LST.StkPop command removes the top value from the stack and optionally stores it in a variable.
Syntax
LST.StkPop|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 - (Optional) The variable to store the popped value. If omitted, the value is placed on the Top of Stack (TOS).
Example
'***********************************
' LST.StkPop Sample Script
'***********************************
' Create a new list container
LST.New|$$LST
' Push values onto the stack
LST.StkPush|$$LST|10
LST.StkPush|$$LST|20
' Pop the top value
LST.StkPop|$$LST|$$VAL
' Display the popped value
DBP.$$VAL
' End the script
ENR.
Remarks
-
Limitations:
- If the stack is empty, the command will return an error or an empty value.
See also:
• LST.StkPush - Push a Value onto the Stack
• LST.StkPeek - Peek at the Top Value on the Stack