
VB 5.0 and Inter-language Data Type Conversions (COBOL) and Parameter Passing
There is a difference in the definition of Strings and Fixed lenght strings
Strings are stored as pointer to null terminated strings
Fixed lenght strings are stored in place.
So:
01 myBuffer.
05 myArray1 pic x(10) occurs 16 times.
05 myArray2 pic x(10) occurs 16 times.
05 myVar1 pic s9(9) comp-5.
05 myArray3 pic x(10) occurs 16 times.
05 myVar2 pic s9(9) comp-5.
TYPE MyBuffer
myArray1 as string * 160
myArray2 as string * 160
myVar1 as long
myArray3 as string*160
myVar2 as long
END TYPE
or
TYPE MyBuffer
myArray1(0 to 159) as byte
...
Sorry if this is a newbie question.
I have an existing COBOL application that has a well defined interface. I can create standard Windows DLLs with no problem. I can even create ActiveX or OCX controls with it. I am trying to find a solution to a problem dealing with returning a COBOL Structure (which will only use VB data types such as longs, strings, etc). The problem is that the structure contains (as part of it anyway) arrays of fixed length strings separated by other data types such as long.
For example
Visual Basic Definition
dim myArray as String * 10
Type myBuffer
myArray1[16] as myArray
myArray2[16] as myArray
myVar1 as Long
myArray3[16] as myArray
myVar2 as long
End Type
NOTE: The syntax of this may not be exactly right, but, what I want is a string with a fixed width of 10 characters that occurs 16 times for the myArrayx.
COBOL Definition
01 myBuffer.
05 myArray1 pic x(10) occurs 16 times.
05 myArray2 pic x(10) occurs 16 times.
05 myVar1 pic s9(9) comp-5.
05 myArray3 pic x(10) occurs 16 times.
05 myVar2 pic s9(9) comp-5.
Because of the way VB handles strings I lose everything after the first array myArray2. I am thinking of try to just return a string buffer that is the length of all of the data in myBuffer. The question is how do I separate out the long data and keep it in that format. That is take four bytes out of a string and say this is really a long.
I hope this is clear enough. Let us say we had a buffer 10 bytes long. The first 4 bytes were a string. The next 4 bytes were actually a long in native format and the last 2 bytes were a string. How would you part the long out of the middle of that string and treat it as a long. The hex value of that four bytes would look something like X'00000001' for the number 1.
Any thought would be welcome.