VB5 calling CW4 DLLs 
Author Message
 VB5 calling CW4 DLLs

My VB5 application needs to get a record from a Clarion Database, so I built
a Clarion DLL to do the file access.

VB Books Online says you can pass a BSTR ByVal, and sure enough Clarion was
fooled into thinking it was getting a *CSTRING ByRef!!  -  So far so good

The only trouble is I can only seem to pass one string per call, further
string parameters in the procedure call just make the DLL bomb out.

Does anybody know how to pass more than one string at a time from VB5 to a
CW4 DLL, or better still a string array?




Mon, 15 Jan 2001 03:00:00 GMT  
 VB5 calling CW4 DLLs
You could try passing a formated command. Something like
FileName<28>Key<28>FieldValue<28>FieldValue<28>FieldValue
and have BOTH programs set up to encode/decode the passed string.

I know, there has got to be a better/faster way, but I don't use VB and
I haven't switched to C4, soooo......

Still on CW2003 / CPD2.1 r 2110 & LPM 2.5 here!



Mon, 15 Jan 2001 03:00:00 GMT  
 VB5 calling CW4 DLLs
Bob,

You cannot pass a string to Clarion by value. Pass by address.  For every
cstring parm you want to receive in your DLL prototype as ULONG not as
*CSTRING.  When using *CSTRING Clarion expects the address and a length
value.  Visual Basic (and most other languages) will only pass the address.
The RAW attribute is not allowed on a prototype for a Clarion procedure.

Because you are only getting an address you will have to build your own
parser to read each byte (using PEEK) starting at the address passed until
you find the null (0). Copy each byte into your STRING or CSTRING using
string slicing.

Reverse the process if you want to return a string.  Because you will not
know the length of the string you will have to assume that the position of
the null indicated the end or you will have to pass another parameter that
has the length.

This is the only way that I have found to pass strings to Clarion from other
languages (and I have tried many).  I have gotten this to work with Access,
VB and Progress.

Good Luck

--
Jeff Jones
Isogon Corporation

Quote:

>My VB5 application needs to get a record from a Clarion Database, so I
built
>a Clarion DLL to do the file access.

>VB Books Online says you can pass a BSTR ByVal, and sure enough Clarion was
>fooled into thinking it was getting a *CSTRING ByRef!!  -  So far so good

>The only trouble is I can only seem to pass one string per call, further
>string parameters in the procedure call just make the DLL bomb out.

>Does anybody know how to pass more than one string at a time from VB5 to a
>CW4 DLL, or better still a string array?





Tue, 16 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Calling Visual Object Cobol DLL′s From VB5

2. calling a MF COBOL .dll (ver 3.2.50) from VB5

3. VB5 Strange Behaviour When Calling Cobol DLL

4. Calling a VB5 DLL from Microfocus COBOL

5. Calling Fortran DLL from CW4

6. Salford F77 + VB5/6 ..DLL possible?

7. MF COBOL CALLED FROM VB5

8. Calling fortran routine in VB5

9. External Dll's not compiled with Clarion in CW4

10. Crystal Reports .DLL with CW2003/and or CW4

11. EXE/DLL CW4 again - HOW?

12. Please Help CW4 Multi DLL app. and GPF

 

 
Powered by phpBB® Forum Software