Page 210 of 346 Start Back Next End ZBasic System Library 198 ZBasic Microcontrollers OpenQueue Type Subroutine Invocation OpenQueue(queue, size) OpenQueue(queue) Parameter Method Type Description queue ByRef array of Byte The queue to be initialized. size ByVal int16 The size of the array, in bytes. Discussion This routine prepares a queue for use by initializing the management information contained in the queue data structure. The number of bytes of space available for data in a queue is the specified size less the queue management overhead (9 bytes). It may be convenient to use the built-in constant System.MinQueueSize in the definition of an array intended to hold a queue. If the compiler can deduce the size of the array element, e.g. an explicitly dimensioned Byte array is specified, the second parameter may be omitted. In this case, the compiler utilizes the size of the array as the size parameter. Otherwise, the compiler will issue an error message indicating that the size must be explicitly specified. Caution If you specify a size parameter that is larger than the actual size of the array, data following the array may be overwritten, usually with undesirable consequences. For this reason, it is recommended that you use the SizeOf() function to specify the queue size so that it will automatically track any changes that you make to the actual queue size. See the example below. OpenQueue() should only be called for a queue that is not in use. Invoking it for a queue that is in use has undefined results. Example Dim inQueue(1 to System.MinQueueSize + 20) as Byte Call OpenQueue(inQueue, SizeOf(inQueue)) After the call to OpenQueue() the queue will ready to be used. Compatibility BasicX allows any type for the first parameter. The ZBasic implementation requires that it be an array of Byte. The second parameter must always be supplied in BasicX mode.