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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mf net express cobol and winapi 3

Status
Not open for further replies.

wadam1972

Programmer
Mar 10, 2006
3
AT
Hello!
I use Net Express Cobol 4. I have already made some mf net expr. cobol programs using WINAPI that work, but I have problems with the following piece of code:

IDENTIFICATION DIVISION.
PROGRAM-ID. cobolwinapi.

ENVIRONMENT DIVISION.
SPECIAL-NAMES.
call-convention 74 is WINAPI.

DATA DIVISION.

WORKING-STORAGE SECTION.

01 uint is typedef pic 9(SZ) comp-5.
01 ulong is typedef pic 9(9) comp-5.
01 DWORD is typedef ulong.
01 wdirname pic x(256).
01 wdirptr pointer.
01 wsize uint.
01 wret dword.

PROCEDURE DIVISION.
Main-Process SECTION.

call "cob32api". *> for int and gnt progs
move spaces to wdirname
move 256 to wsize
set wdirptr to address of wdirname
call "GetCurrentDirectoryA" using
by value wsize
by reference wdirptr
returning wret.

After the call the value of wret is correct - 4 (for "N:\i"), but there is no value in wdirname.
Does anybody know a solution for this?
Thanks in advance
Wolfgang

 
Seems to me you don't need the pointer. BY REFERENCE automatically creates a pointer. Replace "by reference wdirptr" with "by reference wdirname" and see if that doesn't resolve your problem.

Glenn
 
Hello 3gm!
Thanks for your advice, I will try it as soon as possible.
Wolfgang
 
And if you really prefer to use a pointer:
by value wdirptr

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That's right PHV, but that also requires initializing the pointer before you use it.
It must be initialized with the address of a valid memory location large enough to contain the current directory and a null terminator.
Failure to initialize the pointer will raise an access violation calling GetCurrentDirectoryA which will be caught by the Micro Focus RTS which will return runtime error 114 (attempt to access memory beyond bounds of item).
Initializing the pointer goes like this: SET <pointer> TO ADDRESS OF <other variable>.
So you still need another variable, that's why i would not recommend using a pointer here but passing the "real" variable by reference (like 3gm wrote).

Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top