Re: SDL-News: how to define a Queue?


Subject: Re: SDL-News: how to define a Queue?
From: Rick Reed TSE (rickreed#tseng.co.uk)
Date: Thu Aug 10 2000 - 11:47:54 GMT


Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----

Bi Hai at bih#catt.ac.cn wrote on 10/08/2000 03:01:

> I now have little knowledge about how to define a Queue newtype in SDL.
> The declaration of Queue used for storing PDUs as they arrive. I know the PDU
> can be defined as Octet_String type. So I wonder whether I can define a Queue
> as :
> newtype Queue array(integer,Octet_String)
> endnewtype
> Can anyone give me some sugestions and more details about how to define a
> Queue in SDL?

The string construct is more suitable than an Array.

NEWTYPE QueueS String(Octet_String, EmptyOctetString)
ENDNEWTYPE QueueS;

SDL-92 has build in operators: first, last, length, mkstring and substring

The "//" infix operator concatenates Strings.

DCL os Octet_String, osq QueueS;
...
TASK osq := EmptyOctetString; /*intuitively obvious?*/
TASK osq := osq // mkstring (os ); /* add to end */

TASK os := osq(3); /* get 3rd item */
TASK os(i) := os; /* set i'th item */

You will probably want to define additional operators or procedures.
SDL-2000 has the following additional operator: remove.

TASK os:=remove(os,i,j);

which is defined as equivalent to
 substring(os,1,i-1)//substring(os,i+j,length(s)-i-j+1)

WARNING: For Octet_String as defined by Z.105 indexing starts at 1 (just
like any other SDL String). At least one tool incorrectly implemented these
strings to start at 0. For Bit_String indexing starts at zero.

--
Rick Reed - rickreed#tseng.co.uk
Tel:+44 1455 55 96 55 Fax:+44 1455 55 96 58 Mob.:+44 7970 50 96 50

-----End text from Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews ----- For extra SDL Forum Society benefits, join at <http://www.sdl-forum.org/Society/members.htm>



This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT