|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > STK. - Stack > STK.Operations > Stack Operations |
MiniRobotLanguage (MRL)
STK.Reverse
Reverse the order of elements in the stack
Intention
The STK.Reverse command is used to reverse the order of elements in the stack. This operation is useful when you need to process the stack in the opposite order or when the stack's current order does not match your requirements.
The command modifies the stack in place, meaning the original order of elements is permanently reversed.
Syntax
STK.Reverse|P1
Parameter Explanation
P1 - The stack handle. This is typically a variable that contains the handle of the stack.
Example
'***********************************
' STK.Reverse - Sample Script
'***********************************
' Create a new stack
STK.New|$$STK
' Push some values onto the stack
STK.Push|$$STK|First
STK.Push|$$STK|Second
STK.Push|$$STK|Third
' Reverse the stack
STK.Reverse|$$STK
' Pop and display the values
STK.Pop|$$STK|$$VAL
DBP. Popped value: $$VAL
STK.Pop|$$STK|$$VAL
DBP. Popped value: $$VAL
STK.Pop|$$STK|$$VAL
DBP. Popped value: $$VAL
' End the stack
STK.End|$$STK
ENR.
Remarks
-
Limitations:
-
See also:
• STK.New - Create a new stack
• STK.Push - Push a value onto the stack
• STK.Pop - Pop a value from the stack