See Also: #INCLUDE
To incorporate separate source files into DataFlex programs at compile time either as precompiled modules or as source code.
use ["] [{path}]{SourceFileName}[{.ext}]} ["]
Where:
{Path} is optional.
{Path} can be relative or absolute, but is typically relative to the main source path (e.g. AppSrc in a typical workspace).
If {path} contains spaces, the entire path and filename should be enclosed in quotes.
{.ext} is not required if the extension is .pkg, but encouraged.
Use searches for file {SourceFileName.ext} at the time the program is compiled. If the specified file is found and this file has not already been included in the program, its contents are loaded compiled as though they were part of the program. If the file is not found, an error is reported.
A Use package is only included once in a program. If the same package is used more than once in a program, it is included the first time and subsequent use commands are ignored.
use FinFuncs.pkg
In this example, File FinFuncs.pkg is incorporated into the compiling program if it has not already been included in the program with a previous use command.
Any source path may contain subfolder paths. This provides an effective and recommended mechanism for organizing your files.
All subdirectories defined within a source path are considered to be part of the workspace.
Files in these workspace subdirectories must be referenced relative to their location of a main source path. Most often that main source path will be your AppSrc folder.
For example, assume you have the file AccountsEntry.vw located in the following folder structure.
C:\DataFlex Projects
Order Entry
AppSrc
AccountsPayable
Views
AccountsEntry.vw
Reports
AccountsReceivable
Views
Reports
DDSrc
This file is accessed relative to the main source path, AppSrc, and is therefore referenced as follows:
Use AccountsPayable\Views\AcountsEntry.vw
The file will be located relative to your main source paths. In the above example, it will find the file under the AppSrc path (“C:\Dataflex Projects\Order Entry\AppSrc\” + “AccountsPayable\Views\AcountsEntry.vw”).
Note that your use statement must include the entire relative path. The following statement would not find the same file:
Use AccountsEntry.vw // this will not find the same file
In the above example, the file would have to be located directly under a main source path (e.g. …\Appsrc\AccountsEntry.vw).
Subdirectories will be used most often under the AppSrc path. However, subdirectories may be located under and of the main workspace source paths (e.g. AppSrc, DDSrc) and all library source paths. All paths will be searched until the file is found. The path defined as AppSrc is always searched first.
Precompiled portions of source code may be incorporated into your programs by pre-compiling the package file and placing a use {SourceFileName.pkg} statement as the first (non comment) line of your program. This saves time in compilation of the overall program. If the precompiled file is missing, or some other non comment statement precedes the use command, the {SourceFileName.pkg} file will be recompiled as usual. This technique is typically used to use your pre-compiled "all entry" package – the package that includes all packages normally used by your application.
The default name for the DataFlex standard "all entry" package for Windows projects is DFAllent.pkg. The default name for the DataFlex standard "all entry" package for web projects is AllWebAppClasses.pkg.
// top of program
use DfAllent.pkg // this can (and should) be precompiled
use FinFuncs.pkg // this cannot be precompiled
Used files may themselves use other files, without limit. If through this or some other occurrence, the same {SourceFileName.ext} file is used more than one time, the file will be included only the first time. This is a key difference between use and the #INCLUDE compiler directive.