PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Implementation
  • Including the files of the Cobol interface of WINDEV
  • Loading the WINDEV library (WDL)
  • Running WINDEV codes from the external language
  • Ending the application
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
We are going to call the elements developed in WINDEV (project, windows, analysis, and so on) from the Cobol language. The WLanguage code used from the external language will be dynamically compiled and run during its call.
This mode is illustrated by the City.cbl project (in Cobol format) supplied in the "ExternalLanguages\Cobol" sub-directory of the setup directory of WINDEV.
Note: The Cobol language does not allow you to use the HyperFileSQL engine. To handle the HyperFileSQL engine, perform the necessary WLanguage processes in WINDEV.
Implementation

Including the files of the Cobol interface of WINDEV

The following files must be included in a Cobol project in order to call the Cobol interface of WINDEV:
  • WDDEB.CBL
  • WDFIN.CBL
  • WINDEV.CPY
The following lines must be found in the code of the main ".CBL" file of your Cobol project:
* set ans85 noosvs mf defaultbyte"00"
IDENTIFICATION DIVISION.
PROGRAM-ID. WINDEV.
special-names.
call-convention 3 is WINAPI.
data division.
working-storage section.
* Mandatory declaration file
copy "Windev.cpy".
77  STRCH pic x(255).
77  Control pic x(255).
77  Key pic x(255).
77  SearchType pic 9.
77  chn pic xx.
local-storage SECTION.
linkage section.
01  hInst pic xx comp-5.
01  hPrevInstance pic xx comp-5.
01  lpszCmdLine pic x(120).
01  nCmdShow pic xx comp-5.
procedure division WINAPI using  by value hInst
by value hPrevInstance
by reference lpszCmdLine
by value nCmdShow.
MyWinMain section.
* Mandatory initialization of WINDEV
copy "WDDEB.CBL".
These lines allow you to retrieve the minimum declarations required to use the external interface.
Loading the WINDEV library (WDL)
The WINDEV library (.WDL extension) contains all the project elements (windows, reports, classes, queries, analysis, ...). Therefore, it must be loaded in memory in order for its components to be called.
Caution: If the library to load contains windows, the code of each one of these windows must be included in the corresponding ".WDW" file ("Include the compiled code" must be checked in the "Details" tab of the description of each window).
* Opening the library
* if WDInt is not null, the library
* was not found!
call CALLWD using
by reference "Library,disk,city.wdl" & x"00"
if (WDInt = 0)
move " " to WDKey
...
else
* Library not found
call CALLWD using
by reference "Error, Library not found" & x"00"
end-if
Running WINDEV codes from the external language
1. Calling a WLanguage code
All the WLanguage functions can be called from the external language. The behavior of these WLanguage functions as well as the returned values are identical whether they are called:
  • from WINDEV or
  • from the interface of external language
To find out the parameters and the return values of a WLanguage function, see the online help or the documentation about WLanguage.
The call to a WLanguage procedure from the external interface is performed by CallWD. For example:
* open the first window of the program that contains the menu
call CALLWD using
by reference "Open, menuWdn.wdw" & x"00"
2. Retrieving the events triggered in the WINDEV windows
The input in the WINDEV windows requires to retrieve the events triggered in these windows.
To retrieve the user events (click on a menu, on a button, ...), you must implement a system based on a loop in your Cobol program. This loop will remain active as long as the WINDEV window is opened and it will be used to intercept each user action.
To find out the type of action performed by the user, you have the ability to use a character string variable (in WLanguage) named 'WDKey'. This variable will be used in your WLanguage code to signal to the Cobol program which button has been pressed for example.
Example: Cobol code
* open the first window of the program that contains the menu
call CALLWD using
by reference "Open,menuWdn.wdw" & x"00"
* the program loops until the File Exit option
* is selected
Perform MENUINPUT with test before until (WDKey = "ESC")
...
MENUINPUT.
* perform the input of the menu
call CALLWD using
by reference "Screen,Edit" & x"00"
* the status report WDKey is set to *M* when a menu choice
* was selected
if (WDKey = "*M*")
move WDString to chn
*---------------------------------------
* Decode the selected option.
* WDString contains the sequence of shortcut letters
* that are used to select the menu choice
*---------------------------------------
if (Str = "FQ")
Move "ESC" TO WDKey
end-if
...
end-if.
Code for intercepting the selection of "File..Exit" of the WINDEV "Menu" window:
* the program loops until the File Exit option
* is selected
Perform MENUINPUT with test before until (WDKey = "ESC")
...
if (Str = "FQ")
Move "ESC" TO WDKey
end-if
...
* Done...
copy "wdfin.cbl".
exit program returning zero.
stop run.
When the user clicks "File..Exit", WDKey will be equal to "ESC".
Note: The WDKey variable being a character string, its content can be a detailed description of the action to perform. For example, "Close the application".
Ending the application
To end the use of external interface, type the following code lines:
* Done...
copy "wdfin.cbl".
exit program returning zero.
stop run.
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment