1. Calling a WLanguage codeAll 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.
You can use
CallWD to call a WLanguage procedure from the external interface. 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".