CORBA Sequence Examples

Sequences are bound in Methods. If the sequence length exceeds its bound, an exception is thrown. For example, in the following Method script the sequence has 11 members but can only have 10 members.
	
	seqTest   = Module1.CorbaTests.SeqTest("SeqTest")
	stringSeq = [ "1", "2", "3", "4", "5", "6", "7", "8", 
	                    "9", "10", "11" ]
	
	boundStringSeqOp seqTest using
	aBoundStringSeq = stringSeq returning stringSeq
	
	display stringSeq
	
When this example is run, it displays the following exception on the screen:
Exception:
Sequence size is incorrect, it is 11 and should have been 10.

line=5
column=1

Sequences of primitive types

Any of the primitive types shown in Primitive types can be used to create a sequence. The following example shows how to create a string sequence.

	seqTest = Module1.CorbaTests.SeqTest("SeqTest")
	
	stringSeq = ["one", "two", "three"]
	
	stringSeqOp seqTest using aStringSeq = stringSeq
	
	returning stringSeq
	
	display stringSeq
	

Sequences of Structs

The Method script below shows how structure sequences can be used in the Method.
	ts = 'now' // timestamp
	
	seqTest = Module1.CorbaTests.SeqTest("SeqTest")
	
	// create the first struct
	structOne = Module1.CorbaTests.SeqTest.TestStruct()
	structOne.longMember = 10
	structOne.stringMember = String(ts)
	
	// create the second struct
	structTwo = Module1.CorbaTests.SeqTest.TestStruct()
	structTwo.longMember = 20
	structTwo.stringMember = String(ts)
	
	// the array of structures
	structSeq = [structOne, structTwo]
	
	testStructSeqOp seqTest using
	
	aTestStructSeq = structSeq
	

Sequence of Unions

Using sequences of unions is the same as using sequences of structs, as shown in this example:
	ts = 'now' // timestamp
	
	seqTest = Module1.CorbaTests.SeqTest("SeqTest")
	
	unionOne = Module1.CorbaTests.SeqTest.TestUnion()
	unionOne.longMember = 10
	
	unionTwo = Module1.CorbaTests.SeqTest.TestUnion()
	unionTwo.stringMember = String(ts)
	
	unionSeq = [unionOne, unionTwo]
	
	testUnionSeqOp seqTest using
	
	aTestUnionSeq = unionSeq
	

Sequences as INOUT/OUT parameters

Sequences can also be passed as OUT or INOUT arguments in operation invocations. Note that when using sequences of structures or unions as OUT arguments, the restriction that these objects must be instantiated first before being used is still applicable, shown as follows:
	seqTest = Module1.CorbaTests.SeqTest("SeqTest")
	
	// union is instantiated
	testUnion = Module1.CorbaTests.SeqTest.TestUnion()
	testUnion.stringMember = "aString"
	
	testUnionSeqOutOp seqTest returning
	
	// union will be received in the sequence
	testUnionSeq = aTestUnionSeq
	
	unionOne = testUnionSeq[0]
	unionTwo = testUnionSeq[1]