Include_Text Command
See Also: Include_Resource
Purpose
Include_Text allows .SQL and other text files to be included as constants with a single line of DataFlex code.
Syntax
Include_Text
fileName
as
resourceName
Argument Explanation
-
fileName: The name of the resource file to embed in the compiled program. The contents of the file should be in UTF-8 format, as all source code.
fileNamemay be between 1 and 4096 characters in length, must start with a letter, and may not contain spaces. Recommended characters are0-9,a-z,A-Z, and_(underscore). -
resourceName: The name to associate with the embedded file. This name can be used as if defined like a Define or #REPLACE. This command creates
resourceNameas a constant.
What It Does
Include_Text allows .SQL and other text files to be included as constants with a single line of DataFlex code.
Example
This example creates the C_SQLUpdateCustomers constant, which can be used in code and contains the full contents of the file UpdateCustomers.sql.
Include_Text UpdateCustomers.sql as C_SQLUpdateCustomers
Variant vResult
Get SqlExecDirect of ghoSQLExecutor C_SQLUpdateCustomers to vResult
Notes
-
The inclusion happens at compile time and is added to the data area of your application, which has a maximum size of 80 MB; so the sum of all included files cannot exceed that limit. If this limit is exceeded, it will trigger a compiler error
4331 Source not compatible: the file is too large to include. -
Since
Include_Textuses the data area of the compiled program, it allows the program to directly access it from memory and is similar to a constant string you have defined, so you can immediately use it as a string. -
Include_Resource appends files at the end of the compiled program. However, they are outside of the data area or the C-equivalent data segment. This requires resources to be accessed through the I/O API, which is logical for large files.
-
Include_Texttriggers a recompile if the included file has changed.