|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > STK. - Stack > STK.Operations > Stack Operations |
MiniRobotLanguage (MRL)
STK.Peek
Peek at the top value on the stack without removing it
Intention
The STK.Peek command allows you to inspect the top value on the stack without removing it. This is useful when you need to check the value at the top of the stack before deciding whether to pop it or perform other operations.
The command returns the value in the specified variable (e.g., $$RET). If the result variable is omitted, the value is placed on the Top of Stack (TOS).
Syntax
STK.Peek|P1[|P2]
Parameter Explanation
P1 - The stack handle. This is typically a variable that contains the handle of the stack.
P2 - (Optional) The variable to store the peeked value. If omitted, the result is placed on the Top of Stack (TOS).
Example
'***********************************
' STK.Peek - Sample Script
'***********************************
' Create a new stack
STK.New|$$STK
' Push some values onto the stack
STK.Push|$$STK|Hello
STK.Push|$$STK|123
STK.Push|$$STK|3.14
' Peek at the top value
STK.Peek|$$STK|$$TOP
DBP. Top value on stack: $$TOP
' 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