Stack Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Arrays and Data-Structures > STK. - Stack > STK.Operations >

Stack Operations

STK.Pop

Previous Top Next


MiniRobotLanguage (MRL)

 

STK.Pop

Get and remove the top value on the stack

 

 

Intention

 

The STK.Pop command is used to retrieve and remove the top value from the stack. This is a fundamental operation in stack manipulation, allowing you to process data in a Last-In-First-Out (LIFO) manner. The value can be of any type (string, integer, float, etc.), depending on the stack's configuration.

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.Pop|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 popped value. If omitted, the result is placed on the Top of Stack (TOS).

 

 

Example

 

'***********************************

' STK.Pop - 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

' Pop the top value from the stack

STK.Pop|$$STK|$$TOP

DBP. Popped value: $$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.Peek - Peek at the top value on the stack