ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / 
  • Deleting the alias
  • Physical data file associated with an alias
  • Advantages compared to the HAlias function
  • Alias and queries
  • Handling the alias file and its items
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
The Alias type is used to declare and handle a logical alias for a data file or query.
Reminder: An alias allows you to:
  • work on different physical data files with the same logical description.
  • have multiple "pointers" to the same file to do nested iterations.
For example, for a data file:
  • the data file is described in the analysis.
  • the data file alias is created using a variable of type Alias.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Create an alias for the "Order" data file
OrderCheck is Alias of Order
// "OrderCheck" can now be used in processes.
// It behaves like the "Order" data file described in the analysis.
// -------------------
// By default, the name of the physical file associated to the alias corresponds to the
// name of the physical file associated with the source file
// ---------------------------
// To use a file on another database or in another directory,
// you must use HChangeConnection or HChangeDir
Remarks

Deleting the alias

The alias is automatically destroyed at the end of the process where it was declared.

Physical data file associated with an alias

By default, the alias and source file have:
  • the same physical file name.
  • the same connection.
  • the same password.
  • the same physical location.
To associate the alias with a physical data file that has a different name, use HChangeName. If necessary:

Advantages compared to the HAlias function

Any directory, connection or password changes made before the alias is created are automatically taken into account when the alias is defined.
For example:
  • Code used with HAlias:
    HChangeDir(My_File, "New path")
    HChangeConnection(My_File, MyConnection)
    HPass(My_File, "pswrd")
     
    HAlias(MyAlias, My_File)
    HChangeName(MyAlias, My_File.PhysicalName)
    HChangeDir(MyAlias, "New path")
    HChangeConnection(MyAlias, MyConnection)
    HPass(MyAlias, "pswrd")
  • Code used with a variable of type Alias:
    HChangeDir(My_File, "New path")
    HChangeConnection(My_File, MyConnection)
    HPass(My_File, "pswrd")
    MyAlias is Alias of My_File

Alias and queries

To create an alias for a query created in the query editor, simply:
  • run the initial query.
  • declare a variable of type Alias and specify the query name and the alias name.
  • use HExecuteQuery with the alias query. The alias is initialized.
Remark: When creating the alias, the initial query must have been run.
Example:
IF HExecuteQuery(QRY_Query1) = False THEN
Error(HError(hErrCurrent))
ELSE
HReadFirst(QRY_Query1)
Trace(QRY_Query1.City)
QueryAlias is Alias of QRY_Query1
IF HExecuteQuery(QueryAlias) = False THEN
Error(HError(hErrCurrent))
ELSE
FOR EACH AliasQuery
Trace(QueryAlias.City)
END
END
END

Handling the alias file and its items

  • In the window or page editor, controls cannot be directly bound to the items of the alias files. You must:
  • The alias files can be handled by HListItem and HListKey. The alias files can be re-indexed.
  • By default, the password of an alias file is identical to the password of the initial data file. This password can be changed using HPass. The name of the data file used in this function corresponds to the name of the alias.
  • The automatic modification of the data files can be applied to the alias files.
  • The locks performed on the data files or on the records are effective between the aliases of the same instance of an application.
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 10/02/2023

Send a report | Local help