ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL Client/Server functions / WLanguage procedure
  • WLanguage procedure executed in the main thread
  • WLanguage procedure executed in a secondary thread
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
WLanguage procedure called by HWatch
WLanguage procedure ("callback") called by HWatch when a change is made on the specified data file.
Example
// Lance la surveillance du fichier de données Commande
// La procédure TraiteCommande est appelée pour tout ajout d'enregistrement dans le fichier de données
HWatch(Commande, TraiteCommande, hRecNumAll, hsAdd)

PROCEDURE TraiteCommande(NomFic, NumEnreg, Action)
IF BitwiseAND(nAction, hsAdd) = hsAdd THEN
	Trace("Un ajout a été effectué dans le fichier de données : " + NomFic)
END
Syntax
HWatch_Callback(<Modified data file> , <Record number> , <Action>)
<Modified data file>: Character string
Name of the modified HFSQL data file.
<Record number>: Integer
Number of the modified record (equivalent to the number returned by HRecNum).
<Action>: Integer constant
Action that triggered the procedure. The possible values are:
hsAddProcedure started once a record is added into the data file.
hsCrossProcedure started once a record is crossed in the data file.
hsDeletionProcedure started once a record is deleted from the data file.
hsModificationProcedure started once a record is modified in the data file.

Caution: If a process adds a record modifies this record immediately after, HWatch is called once with a combination of the constants hsAdd and hsModification.
To identify these actions in Procedure WLanguage, you need to use the BitwiseAND function. . For example:
IF BitwiseAND(nAction, hsAdd) = hsAdd THEN ...
Remarks

WLanguage procedure executed in the main thread

By default, this WLanguage procedure is called in the main thread of the application, with the HFSQL context that corresponds to the procedure:
  • If the procedure is a local procedure of a window that uses an independent context, the context of the window will be used.
  • If the procedure belongs to a component that uses an independent context, the context of the component will be used.
Caution:
The procedure associated with HWatch can be called at any time in the application.
If the procedure reads records or moves between records in the data files, this will have an impact on the application (like the timers).
Therefore, you may have to call HSavePosition and HRestorePosition to save the contexts of files used.
Multitask must not be used in the procedure code.

WLanguage procedure executed in a secondary thread

If the WLanguage procedure is called in a secondary thread:
  • the HFSQL context is copied the first time WLanguage procedure called by HWatch is called. Only the directories containing the data files in HFSQL Classic mode and/or the connections in HFSQL Client/Server mode are stored.
    Remark: If HChangeDir is called between two calls to the WLanguage procedure called by HWatch function, HChangeDir is ignored. Example:
    HWatch(AFile, hSecondaryThread)
    // The HChangeDir function is ignored
    HChangeDir(AnotherFile)
    HWatch(AnotherFile, hSecondaryThread)
  • UI elements (windows, controls, etc.) cannot be manipulated in the secondary thread. When a secondary thread must interact with the user or update the UI, it must use a process started from the main thread. This process can correspond to:
    • a global procedure of the project or a local procedure (of a window, etc.) called by ExecuteMainThread,
    • the "Request for refreshing the display" event of a window run by RequestRefreshUI.
Business / UI classification: Neutral code
Component: wd290hf.dll
Minimum version required
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2024

Send a report | Local help