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

Calling Win32APi in Fujitsu Cobol 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi,
I was trying to work with Fujitsu Cobol, and got interested in API programming in Cobol. I got my dead end with parameter declarations like in 'CreateDirectory' what to declare for security attributes. Can anyone help me to declare these parameters correctly.
Thanks
Saju
 
Go to search support samples and download it (windows API).
The fujitsu cobol provides, also, cbl routines for create directory or similar (see the samples on fujitsu cobol).
fsccdm
 
Hello Saju

Using Win API calls id quite simple with Powercobol.

I suggest you to download a good Api reference from The samples included in this guide are for Vb developers, but with a few modifications you can use them with Powercobol.

Send me your email at softline2000@tin.it.
I'm pleased to send you some Powercobol prj with Api calls.

Let me know....

Gianni
alias Tromba
 
Hi again Saju

This is a little sample Vb code that is using the "CreateDirectory":

'In general section
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Private Sub Command1_Click()
'KPD-Team 1998
'URL: 'E-Mail: KPDTeam@Allapi.net
Dim Security As SECURITY_ATTRIBUTES
'Create a directory
Ret& = CreateDirectory("C:\Directory", Security)
'If CreateDirectory returns 0, the function has failed
If Ret& = 0 Then MsgBox "Error : Couldn't create directory !", vbCritical + vbOKOnly
End Sub

****
Steps to translate the sample in Powercobol:

- First, load the library "Kernel32.lib" from \Fujitsu Cobol\COBOL\ using the Insert file project option.

- On Working-Storage section declare:
01 SECURITY GLOBAL.
02 nLength PIC S9(9) COMP-5.
02 lpSecurityDescriptor PIC S9(9) COMP-5.
02 bInheritHandle PIC S9(9) COMP-5.

01 pathname PIC X(128).
01 RESULT PIC S9(9) COMP-5.

- On the script event or procedure:
MOVE "MyFolder" TO PATHNAME
CALL "CreateDirectoryA" WITH STDCALL LINKAGE
USING BY REFERENCE PATHNAME
BY VALUE SECURITY
RETURNING RESULT
EVALUATE RESULT
WHEN 0
INVOKE POW-SELF "DISPLAYMESSAGE"
USING "Errors on folder creation"
WHEN OTHER
INVOKE POW-SELF "DISPLAYMESSAGE"
USING "DONE"
END-EVALUATE


That's All.

Hope in this help.

Gianni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top