Stack Operations

<< Click to Display Table of Contents >>

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

Stack Operations

STK.Push

Previous Top Next


MiniRobotLanguage (MRL)

 

STK.Push

Push a value to the top of the stack

 

 

Intention

 

The STK.Push command is used to add a value to the top of the stack. This is a fundamental operation in stack manipulation, allowing you to store 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 requires a valid stack handle and the value to be pushed onto the stack. If the stack handle is invalid, the operation will fail.

 

 

 

Syntax

 

 

STK.Push|P1|P2

 

 

Parameter Explanation

 

P1 - The stack handle. This is typically a variable that contains the handle of the stack.

P2 - The value to be pushed onto the stack. This can be a variable or a literal value.

 

 

Example

 

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

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

' Get the number of items in the stack

STK.Count|$$STK|$$CNT

DBP. Number of items in stack: $$CNT

' End the stack

STK.End|$$STK

ENR.

 

 

Remarks

 

-

 

 

Limitations:

-

 

See also:

 

STK.New - Create a new stack

STK.Pop - Pop an item from the stack

STK.Count - Get the number of items in the stack