Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent to Datatype Long in VB 1

Status
Not open for further replies.

sblueml

Programmer
Jun 17, 2003
6
DE
Which datatype do I have to use if I want the same behaviour as datatype "Long" in Visual Basic?

I have a c-dll which does something with this Long, if I call it from VB it works, if I call it from MF Cobol with pic 9(9) comp-5 it doesn't work.

Thanks for any help
Stephan
 
How does "doesn't work" not work? We need something a bit more specific...

Tom Morrison
 
If I use, let's say a dll example.dll which exports a function called exampleFunction with one parameter input and a integer result the declaration of this function in VB should look like:

Private Declare Function exampleFunction Lib "example.dll" _
(ByVal input As Long) As Long

The call of this function would be:

Dim input As Long
Dim result as Long
input = 5
result = exampleFunction (input)

In MF Cobol, the calling of the dll works, but the parameter input isn't given correctly because I don't know which cobol datatype looks the same like the vb datatype Long in memory.

Hope this explanation helps you to understand my problem.

Stephan
 
Stephan,

I presume that when you say "In MF Cobol, the calling of the dll works" that you have debug print or something else in the C DLL that informs you that the C function is entered.

PIC 9(9) COMP-5 seems the logical analog to a C/VB long, i.e. 32-bit integer. It is possible that MF COBOL is not doing a call by value (which is what your VB Declare specifies) so that your C function is actually receiving the address of the 32-bit data, rather than the 32-bit data itself. Does the data the C function is getting look like an address? Have you tried the COBOL CALL ... USING param BY CONTENT (which is the COBOL equivalent to VB ByVal)?

I am not an expert on MF COBOL, so I will not be able to offer any more help than this. There is a "Micro Focus solutions" forum on Tek-Tips, should you need more help and none is forthcoming in this Forum.

Tom Morrison
 
Tom,

yes, I get a debug print which tells that the function is entered.

For example, if I call a function startSession of the dll the dll returns the number of started sessions. So if I call it a few times I should get these values:

1
2
3
4
5
etc.

But instead I get (using pic9(9) comp-5):
01
11
21
31
41
etc.

I'm a little surprised that the error occurs as a decimal error and not as a binary or hexadecimal error.

Of course I could cut the last position and add 1 to the result, but I would prefer to understand the problem.

Stephan
 
As a last attempt to help, a request...

Please post your C function prototype, and the pertinent COBOL code (data declarations and CALL statements).

Tom Morrison
 
Hi Stephan,

This might help. If you can provide a hex representation of a "long" datatype we may be able to develope a COBOL PICTURE from that.

For example, show us what a positive 123 looks like in memory. Do the same for a negative 123 and an unsigned 123. Include whatever leading zeros are generated by specifying the datatype, as well as any signs, etc.

I'm not familiar with the PC (ASCII) environment, so I'll be guessing here to give some examples, but an
unsigned "long" variable with a value of 123 might look like X'2030313233', a positive 123, like X'2B30313233', a negative 123, like X'2D30313233'. Or a positive 123 can look like X'3030303030313243', etc.

I'm sure I have the values are all wrong, but they attempt to show the leading zeros, signs and the like.

Regards, Jack.
 
Try using comp-x instead of comp-5 and if that doesn't work keep increasing the picture length until it does.

Hope that helps!

Clive
 
"BY CONTENT" should work. Have you tried that. If not, please do and report the results.
 
Yes, well put, webrabbit, and a star for you.

Tom Morrison
 
Microfocus Cobol using Cobol 2002

try

$SET MF INTLEVEL"4"

Working-Storage section.

01 var-1 pic 9(38).

Marcos
Brasil
 
Thanks a lot for all of your replies.

Until now my questions intended to help a colleague in using a c-dll written by another colleague. Because he wasn't able to do this I will now try it by myself. I have used the dll from different programming languages and environments already (so it's sure that the dll works correctly).

I think it will take a few days until I got MF Cobol installed on my pc and then I will try your hints and reply on them. So please be patient for a few days.

Stephan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top