|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > STK. - Stack > STK.-Clone > STK.Clone - Clone Stack |
MiniRobotLanguage (MRL)
STK.Clone
Clone the stack and return the handle to the cloned stack
Intention
The STK.Clone command creates an exact copy of the specified stack, including its data type and content. The cloned stack is independent of the original stack, meaning modifications to one stack will not affect the other. This is useful when you need to preserve the state of a stack for later use or comparison.
The handle to the cloned stack is returned in the optional parameter $$CLN. If $$CLN is omitted, the cloned stack handle is placed on the Top of Stack (TOS).
Syntax
STK.Clone|P1[|P2]
Parameter Explanation
P1 - $$STK The handle of the original stack to be cloned.
P2 - $$CLN (optional) The variable to store the handle of the cloned stack. If omitted, the handle is placed on the Top of Stack (TOS).
Example
'***********************************
' STK.Clone - Sample Script
'***********************************
' Create a new stack
STK.New|$$STK|s
' Push values onto the stack
STK.Push|$$STK|Hello
STK.Push|$$STK|World
' Clone the stack
STK.Clone|$$STK|$$CLN
' Pop and display values from the cloned stack
STK.Pop|$$CLN|$$RES
DBP.$$RES
STK.Pop|$$CLN|$$RES
DBP.$$RES
' End the script
ENR.
Remarks
-
Limitations:
- The original stack must not be empty when using this command.
See also:
• STK.New
• STK.Push
• STK.Pop