Passing Array of UDT Fixed-Length Strings 
Author Message
 Passing Array of UDT Fixed-Length Strings

In an In-Process OLE Server, I am building an array of UDT fixed length
strings.  How do I pass the array back to the client program.  I've seen
references to passing the data as an object, but I'm not sure how to do
that.

----------
Server Code:

MAIN.BAS

Sub Main
    Type WORK_TYPE
        Flag1 As String * 1
        Flag2 As String * 1
        Detail As String * 132
        User As String * 8
        Filler As String * 2
    End Type
End Sub

-----

WORK.CLS

Public nInputNbr As Integer

Sub OpenInput()
    nInputNbr = FreeFile
    Open "E:\Input.TXT" For Binary As nInputNbr
End Sub

Sub ReadInput()
    Dim WorkRecord(1 To 200) As WORK_TYPE
    Get nInputNbr, , WorkRecord
End Sub

How do I get the data in WorkRecord back to a similarly defined array in
the client program.  I would hope there would be a way that I would not
pass field by field, element by element.

Thanks!

Jeff Ziegler
Ziegler Solutions



Mon, 10 May 1999 03:00:00 GMT  
 Passing Array of UDT Fixed-Length Strings

Jeff,

You should use a collection of Workrecord Objects in this case
instead of an array. You could then access the individual
Workrecords on your client program using something like

1.) Declare :  
             dim Workrecords as object
             dim TempObj as object    

2.)Set Reference to Workrecords :

             Set Workrecords = CreateObject("MyDLL.MyCollectionObject")

3.)Use Workrecords

             for idx = 1 to colWorkrecords.Count()
                Set TempObj = Workrecords.Item(idx)  'Get a workrecord Object
                strDetail = TempObj.Detail
             next

Your UDT can be wrapped in a class of its own with no methods
and Public Data members.

Your Work.cls is destined to fail as it is. It is making the assumption
that the datafile you are reading is going to have data in multiples of
200 records. I have *never* seen a data file that I could make that
assumption on and I have dealt with hundreds of different formats
in the past 7 years.

A good VB Object tutorial that I have found indispensible in learning
how to use VB 4.0's Object technology is.

Doing Objects in Microsoft Visual Basic 4.0 - Deborah Kurata  ZD Press

This book even has some discussion on what you are trying to do in this
case. (Reading binary records).

I can send you some samples via email if you are interested in persuing
an object solution to this problem vs. using arrays of UDTs.

Hope this helps,


RBSoft      El Paso, Texas



Quote:

>In an In-Process OLE Server, I am building an array of UDT fixed length
>strings.  How do I pass the array back to the client program.  I've seen
>references to passing the data as an object, but I'm not sure how to do
>that.

>----------
>Server Code:

>MAIN.BAS

>Sub Main
>    Type WORK_TYPE
>        Flag1 As String * 1
>        Flag2 As String * 1
>        Detail As String * 132
>        User As String * 8
>        Filler As String * 2
>    End Type
>End Sub

>-----

>WORK.CLS

>Public nInputNbr As Integer

>Sub OpenInput()
>    nInputNbr = FreeFile
>    Open "E:\Input.TXT" For Binary As nInputNbr
>End Sub

>Sub ReadInput()
>    Dim WorkRecord(1 To 200) As WORK_TYPE
>    Get nInputNbr, , WorkRecord
>End Sub

>How do I get the data in WorkRecord back to a similarly defined array in
>the client program.  I would hope there would be a way that I would not
>pass field by field, element by element.

>Thanks!

>Jeff Ziegler
>Ziegler Solutions




Wed, 19 May 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing an array of fixed length strings.

2. Passing arrays of fixed length strings.

3. Passing fixed length string to API and is returning nulls in string

4. Passing fixed length arrays to C DLL

5. Array of Fixed Length Strings...

6. Using fixed-length strings/byte arrays

7. Fixed length strings in a dynamically allocated array

8. Fixed Length String Arrays w/a variable

9. Copy Memory and Fixed Length String Array!

10. ADOX: Extending a fixed length Jet string field length

11. Fixed String and Fixed Array

12. Length of UDT passed to C-DLL

 

 
Powered by phpBB® Forum Software