<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>Looking for examples of sequence manipulation</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT FACE="Times New Roman">Howdy:</FONT>
</P>
<P><FONT FACE="Times New Roman">Looking for tips on how to manipulate sequences I came across this example in the mailing list archives.</FONT>
<BR><FONT FACE="Times New Roman">The example demonstrates how to create the sequence in idl, and how to pass a pointer to the sequence in the implementation code. Unfortunately, it does not show the syntax required to access this pointer within the implementation after it is created. In other words, after</FONT></P>
<P><I><FONT FACE="Times New Roman"> ptx = new MyInterface::randSeq(len,len,p);</FONT></I>
</P>
<P><FONT FACE="Times New Roman">I'd like to do something with the sequence, like assign a value to something within it.</FONT>
<BR><FONT FACE="Times New Roman">For example if I have declared a sequence like this in IDL</FONT>
<BR><FONT FACE="Times New Roman">Typedef struct theStruct</FONT>
<BR><FONT FACE="Times New Roman">{</FONT>
<BR> <FONT FACE="Times New Roman">short x ;</FONT>
<BR> <FONT FACE="Times New Roman">short y ;</FONT>
<BR><FONT FACE="Times New Roman">} theStructType ;</FONT>
<BR><FONT FACE="Times New Roman">Typedef sequence <theStructType> theStructSeq ;</FONT>
<BR><FONT FACE="Times New Roman">Boolean DoSomethingWithTheStructSeq( out theStructSeq myStructSeq) ;</FONT>
</P>
<P><FONT FACE="Times New Roman">And the implementation has</FONT>
<BR><FONT FACE="Times New Roman">Bool DoSomethingWithTheStructSeq( theStructSeq_out ss )</FONT>
<BR><FONT FACE="Times New Roman">{</FONT>
<BR><FONT FACE="Times New Roman"> theStructSeq *& ptx = ss.ptr() ;</FONT>
<BR><FONT FACE="Times New Roman"> ptx = new theStructSeq(3) ;</FONT>
<BR>
<BR><FONT FACE="Times New Roman">}</FONT>
</P>
<P><FONT FACE="Times New Roman">What is the syntax to assign a value to 'x' within an element of the sequence?</FONT>
<BR><FONT FACE="Times New Roman">Thanks,</FONT>
<BR><FONT FACE="Times New Roman">Dave P</FONT>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> Howdy,</FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> Hope the following sample helps you. </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> IDL:</FONT></I> <FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> interface MyInterface </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> { </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> typedef sequence<octet> randSeq; </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> void getRandSeq( out randSeq tx ); </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> } </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> Object Implementation: </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> void MyInterface_i::getRandSeq( randSeq_out tx )</FONT></I>
<BR><I><FONT FACE="Times New Roman"></FONT></I> <FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> { </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> MyInterface::randSeq*& ptx = tx.ptr(); </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> //....</FONT></I> <FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> CORBA::Octet* p = new CORBA::Octet[ len ]; </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> //.... </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> ptx = new MyInterface::randSeq(len,len,p); </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> }</FONT></I>
<BR><I><FONT FACE="Times New Roman"></FONT></I> <FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> Client:</FONT></I> <FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> void hello( MyInterface_ptr e ) </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> { </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> MyInterface::randSeq_var tx; </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> e->getRandSeq( tx.out() ); </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> long len = tx.length(); </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> for ( i = 0; i < len; i++ ) </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> { </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> cout << tx[i] << endl; // access</FONT></I>
<BR><I><FONT FACE="Times New Roman"></FONT></I> <FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> } </FONT></I>
<BR><FONT FACE="Times New Roman">></FONT><I><FONT FACE="Times New Roman"> }</FONT></I>
</P>
</BODY>
</HTML>