|
|
|
|
|
- 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
External language: Cobol programming
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 in the "City.cbl" project (Cobol format), available in the "External Languages\EN\Cobol" subdirectory of the WINDEV installation directory. Remark: The Cobol external language does not support the HFSQL engine. To handle the HFSQL engine, perform the necessary WLanguage processes in WINDEV. 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. * Fichier de declaration obligatoire copy "Windev.cpy". 77 STRCH pic x(255). 77 Champ pic x(255). 77 Cle pic x(255). 77 TypeRech 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. * Initialisation obligatoire de 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. Attention: If the library to be loaded contains windows, the code for each of these windows must be integrated into the corresponding ".WDW" file (option "Integrate compiled code" checked, in the "Detail" tab of each window description). * Ouverture de la bibliothèque * si WDEntier n'est pas nul, la bibliothèque * n'a pas été trouvée! call APPELWD using by reference "Bibli,disque,ville.wdl" & x"00" if (WDEntier = 0) move " " to WDTouche ... else * Bibliothèque non trouvée call APPELWD using by reference "Erreur, Bibliothèque non trouvée" & x"00" end-if Running WINDEV codes from the external language 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: * ouverture de la première fenêtre du programme contenant le menu call APPELWD using by reference "Ouvre,menufc.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 * ouverture de la première fenêtre du programme contenant le menu call APPELWD using by reference "Ouvre,menufc.wdw" & x"00" * le programme boucle jusqu'à ce que le choix Fichier Quitte * soit sélectionné Perform MENUSAIS with test before until (WDTouche = "ESC") ... MENUSAIS. * on effectue la saisie du menu call APPELWD using by reference "Ecran,Saisie" & x"00" * le compte-rendu WDTouche vaut *M* lorsque un choix de menu * a été sélectionné if (WDTouche = "*M*") move WDChaine to chn *--------------------------------------- * Decodage de l'option choisie. * WDChaine contient la suite des lettres d'appel * qui aboutissent au choix de menu sélectionné *--------------------------------------- if (Chn = "FQ") Move "ESC" TO WDTouche end-if ... end-if. Code for intercepting the selection of "File..Exit" of the WINDEV "Menu" window: * le programme boucle jusqu'à ce que le choix Fichier Quitter * soit sélectionné Perform MENUSAIS with test before until (WDTouche = "ESC") ... if (Chn = "FQ") Move "ESC" TO WDTouche end-if ... * Terminer... 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". To end the use of external interface, type the following lines of code: * Terminer... copy "wdfin.cbl". exit program returning zero. stop run.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|