PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • WLanguage properties that can be used with the Stack type
  • WLanguage functions for managing the stacks
  • The stacks and the multithread
  • Browsing the stacks
  • Special cases
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
A Stack variable is a structured type that is used to group a set of elements of the same type. The elements are added at the end of stack and they are retrieved from the most recent one.
For example, if the elements are added in the following order: 1, 2, 3, they will be retrieved in the following order: 3, 2, 1.
Versions 18 and later
iPhone/iPad This type of variable is now available for the iPhone/iPad applications.
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
New in version 18
iPhone/iPad This type of variable is now available for the iPhone/iPad applications.
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
iPhone/iPad This type of variable is now available for the iPhone/iPad applications.
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Android This type of variable is now available for the Android applications.
Android Widget This type of variable is now available in Android Widget mode.
WINDEVJava This type of variable is now available for the Java applications.
Apple Watch This type of variable is now available in Apple Watch mode.
New in version 21
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Android This type of variable is now available for the Android applications.
Android Widget This type of variable is now available in Android Widget mode.
WINDEVJava This type of variable is now available for the Java applications.
Apple Watch This type of variable is now available in Apple Watch mode.
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Android This type of variable is now available for the Android applications.
Android Widget This type of variable is now available in Android Widget mode.
WINDEVJava This type of variable is now available for the Java applications.
Apple Watch This type of variable is now available in Apple Watch mode.
Example
MyStack is Stack of int

// Push the values 1, 2 and 3
Push(MyStack, 1)
Push(MyStack, 2)
Push(MyStack, 3)

// Display the trace: 3, 2, 1
x is int
WHILE Pop(MyStack, x)
Trace(x)
END
Syntax

Declaring and initializing a stack Hide the details

<Stack Name> is Stack of <Type of Stack Elements>
<Stack Name>:
Name of Stack variable to declare.
<Type of Stack Elements>:
Type of the elements found in the stack.
All types of variables can be used EXCEPT for the arrays, the associative arrays, the queues, the stacks and the lists.
Versions 20 and later
All types of variables can be used including the arrays, the associative arrays, the queues, the stacks and the lists. For example:
<variable> is stack of arrays of int

<variable> is stack of fixed arrays of 5 int

<variable> is stack of associative arrays of int

<variable> is stack of queues of int

<variable> is stack of stacks of int

<variable> is stack of lists of int
New in version 20
All types of variables can be used including the arrays, the associative arrays, the queues, the stacks and the lists. For example:
<variable> is stack of arrays of int

<variable> is stack of fixed arrays of 5 int

<variable> is stack of associative arrays of int

<variable> is stack of queues of int

<variable> is stack of stacks of int

<variable> is stack of lists of int
All types of variables can be used including the arrays, the associative arrays, the queues, the stacks and the lists. For example:
<variable> is stack of arrays of int

<variable> is stack of fixed arrays of 5 int

<variable> is stack of associative arrays of int

<variable> is stack of queues of int

<variable> is stack of stacks of int

<variable> is stack of lists of int
Remarks

WLanguage properties that can be used with the Stack type

The following properties can be used to handle a Stack variable.
Property name
Effect
AdditionCompletedReturns and modifies the addition mode of elements.
This property is used for the multithread management.
NbPendingThreadReturns the number of pending threads.
This property is used for the multithread management.
OccurrenceReturns the number of stack occurrences.
Empty
  • True if the stack is empty,
  • False otherwise.
Note: These properties can be used with one of the following syntaxes:
  • <Variable Name>..<Property Name>
  • <Variable Name>.<Property Name>

WLanguage functions for managing the stacks

The following functions can be used to handle a Stack variable.
Versions 14 and later
DeleteAll
New in version 14
DeleteAll
DeleteAll
Deletes all the elements:
  • from a one-dimensional or two-dimensional WLanguage array.
  • from an associative array.
  • from an advanced array property (array of gglCalendar events, ...).
  • from a WLanguage queue.
  • from a WLanguage stack.
  • from a WLanguage list.
Versions 10 and later
Deserialize
New in version 10
Deserialize
Deserialize
Deserializes a buffer or a character string containing the data of a class, structure, array (including an associative array), queue, stack, list or advanced variable as well as their sub-elements.
Versions 14 and later
Pop
New in version 14
Pop
Pop
Pops an element from a stack.
Versions 14 and later
Push
New in version 14
Push
Push
Pushes an element into a stack.
Versions 10 and later
Serialize
New in version 10
Serialize
Serialize
Transforms the following elements into a specific format:
  • a structure (and its sub-elements),
  • a class (and its sub-elements),
  • an array (including the associative arrays),
  • a queue,
  • a stack,
  • a list.
Versions 16 and later
StackInfo
New in version 16
StackInfo
StackInfo
Retrieves the characteristics of a stack: types of elements and number of elements.

The stacks and the multithread

The management of multithread is taken into account when adding and deleting an element (Push and Pop).
You also have the ability to use properties during a multithread management but the result is not permanent. For example:
IF MyStack..Occurrence > 0 THEN
// The stack may be empty when the thread reaches this point
END

Browsing the stacks

The FOR EACH syntax can be used to browse the stacks. The elements are browsed in pop order that is the reverse order of the push order.
The syntax used corresponds to the one used for the arrays:
FOR EACH [ELEMENT] <Variable> [, <Counter> [, <Counter>]] OF <Stack>
...
END
The elements can be modified during the browse. If the stack is modified during a browse, the elements browsed will be the ones found when the browse was initialized:
  • the elements pushed after the initialization of the browse will not be browsed.
  • the elements popped after the initialization of the browse will still be browsed.

Special cases

  • In the debugger, the content of the stack is displayed in pop order.
  • A stack can be used to type a procedure parameter.
  • A stack can be copied by the = operator. You also have the ability to copy a class or structure instance containing a stack.
  • A stack can be initialized by a list of elements in push order.
Minimum required version
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment