about arrays of arrays.

I have a bunch of string arrays in a table like form.

“Abc”, “DEF”, “123”

dim mylist(-1) as string dim listlist(-1, -1) as string

is that the correct syntax?
Can I append a column and row at a time?

What are you ultimately trying to do with the string arrays?

These are HL7 messages the kinda look like this


[code]dim rows(-1) as AnArrayOfString

for each row in rows
for column or row
print column

Of couse I’ve split the rows using split("|")

Does order of the MSG matter? If not, you could use a dictionary and do something like this:

[code]dim d as new dictionary
dim arsFields() as string

dim ars() as string = sLineOfData.Split("|")
dim sMsg as string = ars(0)
//now remove element 0
d.value(sMsg) = ars

I like it… I just hope the dictionary doesn’t rearrange the order of the rows.

And a more OO way would be to create an HL7 message class. The constructor gets the line of data and the class parses it out so that it knows the message and then has the array of strings in it.

I think you could create a Factory item that creates the right class based on what the MSG is. So if (just making stuff up) if the message is PATIENT you’d end up passing the data to the HL7_Patient class and it would know everything there is to know about the PATIENT message and it might even parse it out into human readable properties. So if Field 0 is ID then the class would put that into the ID property so you can use it elsewhere. If Field 1 is FirstName it puts the data into the Firstname property and so on.

I guess it really depends on the goal of what you’re trying to do. If you’re just trying to view generic data the previous response is better. If you’re integrating it into a real world application the second might be better.

[code] Dim row() As Variant
Dim col() As String
col = Array(“aaa”, “bbb”)
row.Append col
col = Array(“ccc”, “ddd”, “eee”)
row.Append col
col = Array(“fff”, “ggg”)
row.Append col

// retrieve an Array
col = row(1)
MsgBox(col(2)) // show “eee”[/code]

Indeed, the MLLP class which reads the message stream data spits out HL7 messages.

Those two lines of Text are 1 HL7 message. i.e. each line is a segment and a segment has fields and fields have components etc…
So for simplicity sake the HL7 Message is constructed from an array of segments.

and sooo…

an HL7 message IS An Array of Segments.
or an HL7 has an Array of Segments.

I always thought of it as a string array of string arrays. You just keep splitting the string arrays into arrays.

Update - Corrected my bad typing.

Just fyi. A 2D arrays isn’t an “array of arrays” - it’s a single array with 2 dimensions. You cannot get an array out of it by something like:

dim myArray(10,10) as Integer

dim myInts() as Integer = myArray(1) // trying to get one dimension from a 2D array

and this is true of any multi-dimensional array. ie/ a 3D array is not an array of 2D arrays that are arrays of 1D arrays.

[quote=393575:@Brian O’Brien]an HL7 message IS An Array of Segments.
or an HL7 has an Array of Segments.[/quote]
Both? I think it depends on what you’re doing with data afterwards.

If you want an array of arrays you’d have to first declare your array of type variant. Then you can assign arrays into it.

//Not tested in any way
dim myArrayofArrays() as variant.

dim s() as string = Array(“a”, “b”, “c”)
myArrayOfArrays.append s

To get it out then you’d probably have to put it back into an array to work with it.
dim mys() as string
mys = myArrayofArrays(index)
dim s as string = mys(0) //to get the first array

I don’t see any way of doing a shortcut. I really don’t like this approach as it’s nothing but pure data manipulation. You still have to parse the array to figure out what the message is.

This is one of those cases where I’d do see what people are doing in other languages and just copy their implementation.

Or create a class with a property which is an array, then make an array whose elements are members of that class.

Right. There are a dozen ways to approach it. I’d go with the class myself.