ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Managing external languages / Pascal and Delphi
  • Overview
  • Implementation
  • 1. Including the files of the Pascal interface of WINDEV
  • 2. Including the HFSQL declarations
  • Declaration and initialization
  • 1. Declaring the HFSQL context and the working contexts of each file
  • 2. Initializing HFSQL contexts
  • 3. Loading the WINDEV library (WDL)
  • Running WINDEV codes from the external language
  • 1. Calling a WLanguage code
  • 2. Retrieving the events triggered in the WINDEV windows
  • Ending the application
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
We are going to call the elements developed in WINDEV (project, windows, analysis, and so on) from the Pascal 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.PAS project (Pascal format), available in the "External Languages\EN\Pascal" subdirectory of the WINDEV installation directory.
Implementation

1. Including the files of the Pascal interface of WINDEV

If you are using a database in your application, the first step consists in generating your analysis. In the description of this analysis, specify the programming language used as well as the directory that will contain the source files.
Via the generation, a program skeleton (*.pas) is generated. This operation will also create the .h file (see below) required to use your data files.
The following files must be included in a Pascal project in order to call the Pascal interface of WINDEV:
  • Squelet.PAS (contains the description of the analysis)
  • <AnalysisName>.H
  • WDHF.PAS
  • WINDEV.PAS
The .h and .pas files that describe the structure of the data files will be automatically generated by WINDEV when generating the analysis.

2. Including the HFSQL declarations

The .h and .pas files corresponding to the description of the analysis files must be added to the Pascal project. The data file declarations are included in the .h file.
For example, in the City.pas code (provided with WINDEV in the "External Languages\EN\Pascal" directory), these files are "CityPas.H" and "Squelet.PAS".
Declaration and initialization

1. Declaring the HFSQL context and the working contexts of each file

If the application must manage data files, an HFSQL working context must be declared as well as a working context for each data file.
These declarations are performed in the City.pas project via the following lines:
{------------- include des descriptions des fichiers utilisés --------------}
{ pour chaque fichier mettre une ligne $I .WDR }
{$I VillePas.h} (* record    *)
var DP:typeDP;
var VI:typeVI;
{$F+} { directive de compilation  $F+ obligatoire en début }
procedure HDecritEnregistrement;
{Décrit chaque fichier de l'analyse}
VAR
lTabRubDP:array[0..1] of longint;
sTypeDP: String;
lTabRubVI:array[0..1] of longint;
sTypeVI: String;
begin
lTabRubDP[0]:= 31; lTabRubDP[1]:= 3;
sTypeDP:= '11';
LE_HDecritEnregistrement(gCtx, stringtoptr('DEPART'), 34,
longint(@lTabRubDP[0]), 2, stringtoptr(sTypeDP), @DP);
lTabRubVI[0]:= 41; lTabRubVI[1]:= 6;
sTypeVI:= '11';
LE_HDecritEnregistrement(gCtx, stringtoptr('VILLE'), 47,
longint(@lTabRubVI[0]), 2, stringtoptr(sTypeVI), @VI);
End;
procedure HInit;
VAR
{Creation du contexte}
sNomAnalyse:String;
sMotDePasse:String;
begin
gCtx:= LE_CreateContexteHF(2);
sNomAnalyse:= 'VILLEPAS.WDD';
sMotDePasse:= ' ';
{Description de chaque enregistrement}
HDecritEnregistrement;
{Initialisation de HF}
APPELWD('HFCTX');
If LE_Hinitpartage(gCtx,WDLong) = 0 Then
begin
APPELWD('Erreur,Erreur initialisation du contexte HF');
End
{ouverture de l'analyse}
else
begin
If HOuvreAnalyse(gCtx, sNomAnalyse, sMotDePasse, ' ', ' ', ' ') = 0 Then
begin
APPELWD('Erreur,Erreur ouverture de l' 'analyse');
End;
End;
End;

2. Initializing HFSQL contexts

If your application is calling a database, the access to HFSQL must be prepared now. The test below is used to check whether this initialization is performed properly:
{Creation du contexte}
begin
HInit;
End;

3. 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.
The load operation is performed by CALLWD('LIBRA,disk ...') as follows:
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).
begin{ Ouverture de la bibliotheque }
{ si WDEntier n'est pas nul, la bibliothèque n'a pas été trouvée! }
APPELWD('BIBLI,disque,ville.wdl'); { Ouverture de la bibliotheque. }
if WDEntier0 then
begin
{ Bibliothèque non trouvée }
APPELWD('Erreur,La bibliothèque VILLE.WDL doit être présente dans le répertoire père.');
{ on indique à WINDEV que le programme va se terminer }
{ utilisez HFTermine uniquement si une base de données HFSQL est utilisée }
HFTermine;
WDTermine;
Halt;
end;
...
end;
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 done via CallWD. For example:
ouverture de la première fenêtre du programme contenant le menu }
APPELWD('OUVRE,menu.wdw');
You will notice that the parameter expected by CallWD is a character string containing the WLanguage code to run.
Like the WLanguage coded in WINDEV, this string is not case sensitive (uppercase/lowercase characters). Therefore, the "Info" command can also be written as "INFO".

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, and so on), you must implement a system based on a loop in your Pascal 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 Pascal program which button has been pressed for example.
Example: Pascal code
{ ouverture de la première fenêtre du programme contenant le menu }
APPELWD('OUVRE,menu.wdw');
{ le programme boucle jusqu'à ce que le choix Fichier Quitte }
{ soit sélectionné }
while( WDTouche<>'ESC' ) do
begin
{ on effectue la saisie du menu }
APPELWD('ECRAN,saisie');
{------------------------------------------------}
{ Décodage de l'option choisie.  }
{ WDChaine contient la suite des lettres d'appel }
{ qui aboutissent au choix de menu sélectionné   }
{------------------------------------------------}
if( WDTouche='FQ' ) then WDTouche:='ESC';{ Sortie              }
if( WDTouche='RN' ) then RechVille;      { Recherche par Ville }
if( WDTouche='RD' ) then RechDepar;      { Recherche par Dépar }
if( WDTouche='DD' ) then LstDepart;      { Affichage liste.    }
if( WDTouche='DI' ) then LstImprime;     { Impression.         }
if( WDTouche='DC' ) then LstConfig;      { Configuration imp   }
end;
Code of "File .. Exit" of the WINDEV "Menu" window (WLanguage):
if( WDTouche='FQ' ) then WDTouche:='ESC';{ Sortie de la boucle }
When the user clicks "File .. Exit", WDKey will be returned to the Pascal code to perform the next action.
Ending the application
To end the use of the external interface, all you have to do is call HFDoneShare and WDDone that expect no parameter. For example:
{ Terminer... }
{ utilisez HFTerminepartage uniquement si une base de données HFSQL est utilisée }
HFTerminepartage;
WDTermine;
end.
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help