When you compile a class definition file, ABL compiles the class definition file identified in the COMPILE statement and all class files in its inherited class hierarchy, by default. You can direct ABL to compile only those class definition files in the class hierarchy that are not found in the cache, and cache any classes or interfaces it compiles during the session, by setting the MULTI-COMPILE attribute to TRUE.After you compile a procedure file, you use the RUN statement to create an instance of the procedure, and you use a handle to access the procedure and its context. After you compile a class definition file, you use the NEW function (classes) to create an instance of the class, and you use an object reference to access the class-based object, as well as its data members, properties, and methods.For more information about compiling procedure files, see OpenEdge Getting Started: ABL Essentials. For more information about compiling class definition files, see OpenEdge Development: Object-oriented Programming.
COMPILE procedure-pathname class-pathname VALUE ( expression )ATTR-SPACE = logical-expressionSAVE = logical-expressionINTO directory VALUE ( expression )LISTING listfile VALUE ( expression )APPEND = logical-expressionPAGE-SIZE integer-expressionPAGE-WIDTH integer-expressionXCODE expressionXREF xreffile VALUE ( expression )APPEND = logical-expressionXREF-XML directory filename VALUE ( expression )STRING-XREF sxreffile VALUE ( expression )APPEND = logical-expressionSTREAM-IO = logical-expressionLANGUAGES ( language-list VALUE ( expression ) )TEXT-SEG-GROW = growth-factorDEBUG-LIST debugfile VALUE ( expression )PREPROCESS preprocessfile VALUE ( expression )NO-ERRORV6FRAME = logical-expressionUSE-REVVIDEO USE-UNDERLINEMIN-SIZE = logical-expressionlogical-expressionGENERATE-MD5 =procedure-pathname VALUE ( expression )Specifies the name and location of a procedure file you want to compile, where procedure-pathname is the literal procedure pathname and expression is a character expression that evaluates to the procedure pathname. This pathname can be a full (absolute) pathname or it can be a pathname (or procedure filename only) relative to PROPATH. The specified procedure filename must include the extension (.p or .w) whether you specify it alone or as part of a path. On UNIX, filenames are case sensitive, so you must enter them exactly as they are stored. In Windows, the pathname cannot contain characters outside of the non-Unicode code page. See OpenEdge Development: Internationalizing Applications for more information about Unicode and code pages.Specifies the name and location of a class definition file you want to compile. This can be a literal full (absolute) pathname or a literal pathname relative to PROPATH. If it is a relative pathname, the class or interface type name defined in the file must match the pattern of this relative pathname. If the type name is not defined with a package, the relative pathname must specify only the class filename. In all cases, the class filename must include the .cls extension. On UNIX, the class-pathname and corresponding class or interface type name are also case sensitive and must match in letter case as well as spelling. For more information on packages and class or interface type names, see the Type-name syntax reference entry.ATTR-SPACE = logical-expressionXCODE expressionDecrypts the source code in procedure-pathname or class-pathname, and any encrypted include files, using the decryption key expression.
If the XCODE option is provided, then COMPILE uses the key specified by expression. If the key does not match the source file key, then the compilation fails with an error message. Use this option only when the encryption key is not the built-in (default) key or the encryption key for the session.STREAM-IO = logical-expressionIf you specify a logical-expression, its value determines whether the STREAM-IO option is activated. If the logical-expression is evaluated to the Unknown value (?), a run‑time error occurs.If you specify a logical-expression, its value determines whether the SAVE option is activated. If the logical-expression is evaluated to the Unknown value (?), a run‑time error occurs.The COMPILE SAVE statement produces r‑code files with the name procedure-pathname.r or class-pathname.r, where procedure-pathname is the pathname of a procedure source file without the filename extension, and class-pathname is the pathname of a class source file without the filename extension. ABL ignores the filename extension of a procedure or class definition file and always creates r‑code files that use the same filename with a .r extension. For example, if you supply a filename of test, test.p, or test.cls, COMPILE SAVE produces an r‑code file with the name test.r. If you specify a filename of test.bp, COMPILE SAVE still produces an r‑code file with the name test.r.
Caution: Where both procedure and class definition files compile to a .r file, be sure to use distinct filenames. If you have a procedure file and a class definition file with the same name, and you compile them both with COMPILE SAVE, the first .r file will be overwritten by the second .r file.On UNIX and Windows, a newly created r‑code file replaces any existing r‑code file of the same name.The listfile or VALUE ( expression ) identifies the name of the file in which you want to store the Compiler listing. If expression evaluates to the Unknown value (?), then ABL ignores the LISTING option. In Windows, the filename cannot contain characters outside of the non-Unicode code page.APPEND = logical-expressionIf you specify a logical-expression, its value determines whether the APPEND option is activated. If the logical-expression is evaluated to the Unknown value (?), a run‑time error occurs.PAGE-SIZE integer‑expressionIdentifies the number of lines to a page in the listing file. The default page size is 55 and integer-expression must be between 10 and 127, inclusive.PAGE-WIDTH integer-expressionIdentifies the number of page columns in the listing file. The default page width is 80, and integer-expression must be between 80 and 255, inclusive. Add at least 12 spaces to the page width when you type the file. This allows you to list information that precedes each line of code, ensuring that the file appears in the listing output exactly as you typed it.Returns reference information on ABL elements, cross-references between procedures and ABL objects, and cross-references between class or interface definition files and ABL objects. See Table 17 for more information on the type of reference information returned.Information can be written to the file xreffile or VALUE ( expression ). If expression returns the Unknown value (?), then ABL ignores the XREF option.In addition, you can use the APPEND option to add information to an existing file. When you use APPEND, the first line for a procedure contains information for the COMPILE type. This allows you to easily find where the information for each compilation begins. If you specify a logical-expression, its value determines whether the APPEND option is activated. If logical-expression is evaluated to the Unknown value (?), a run‑time error occurs.XREF generates one unformatted, whitespace‑separated line in xreffile for each referenced element. Each line has the following format:
source-name file-name line-number xref-type xref-informationThe source-name is the name of the procedure or class file you compile with the COMPILE XREF statement. The file-name is the name of the file containing the referenced element. For example, file-name could be an include file. Otherwise, file-name is the same as source-name. The line-number is the line number of the statement in file-name that contains the referenced element. The xref-type is the type of reference in the code and xref-information contains details about the reference.
Table 17: database. table fieldDATA-MEMBERWORKFILE TEMPTABLEvariableSHAREDclass-name:data-member-namePUBLIC-DATA-MEMBERINHERITED-DATA-MEMBER
class-name:data-member-namePUBLIC-PROPERTY
class-name:property-nameINHERITED-PROPERTY
class-name:property-namesequence-name SEQUENCEstring
ON ERROR UNDO, THROW1 (-undothrow)2 source-class-nameFROMTO target-class-name class-name, INHERITS inherited-class-nameinherited-class-name ) ,(interface-nameIMPLEMENTSinterface-name ,USE-WIDGET-POOL , FINAL , ABSTRACT procedure class-file PROTECTED,PUBLIC,constructor-name,, STATIC ,,,void, parameter1 , parameter2code‑page‑name-that-ABL-uses‑in‑memory
code‑page‑name-that‑ABL‑uses‑for‑stream‑I/O
DATA-MEMBER INHERITED-DATA-MEMBERclass-name:table-namedatabase. table WORKFILETEMPTABLE PUBLIC PROTECTED , STATIC ,TEMPTABLE BUFFER QUERYDATASET DATASOURCE ,data-member
dataset-name, PROTECTED ,REFERENCE-ONLY ,namespace ,NAMESPACE-URIprefix ,NAMESPACE-PREFIXbuffer-name1 buffer-name2 , DATALINKS DATA-MEMBER INHERITED-DATA-MEMBERclass-name:tabledatabase. table WORKFILE TEMPTABLEclass-name
PUBLIC,,,,destructor-name,void,procedure-name,,
parameter1 , parameter2 function-name,return-type,parameter1 , parameter2 PUBLIC PROTECTED , STATIC ,event-name,OVERRIDE ,, ABSTRACT ,delegate-type-name , return-type,parameter1 , parameter2 Not applicable (Data Servers only) function-name,return-type,parameter1 , parameter2global-variable
include-file-name
interface-type-name,
interface-type-nameINHERITS(interface-type-name ) ,,, class-name:method-nameinvocation-parameter1,invocation-parameter2, PUBLIC PROTECTED , STATIC ,OVERRIDE , FINAL , ABSTRACT ,method-name, return-type,parameter1 , parameter2 class-name , invocation-parameter1invocation-parameter2, dataset-name, PROTECTED ,REFERENCE-ONLY ,namespace ,NAMESPACE-URIprefix ,NAMESPACE-PREFIXbuffer-name1 buffer-name2 ,DATALINKSnew-shared-frame
temptable-name
new-shared-variable
new-shared-workfile
database. tableLIKE PROCEDURE3procedure-name,,
parameter1 , parameter2 function-name, return-type,parameter1 , parameter2procedure-name,,
parameter1 , parameter2 PUBLIC PROTECTED , STATIC ,property-nameOVERRIDE ,, ABSTRACT , PUBLISH4 class-name: event-name (exp) database. table fieldSHARED variableWORKFILEDATA-MEMBER INHERITED-DATA-MEMBERclass-name:table field ON ERROR UNDO, THROW1 (-undothrow)2 procedure-name value(exp)REMOTE SINGLE-RUN SINGLETON SUPER STORED-PROCPERSISTENT SEARCH5 database. tableDATA-MEMBER INHERITED-DATA-MEMBERclass-name:table WORKFILEindex RECID TEMPTABLEWHOLE-INDEX | TABLE-SCAN dataset-name, PROTECTED ,REFERENCE-ONLY ,namespace ,NAMESPACE-URIprefix ,NAMESPACE-PREFIXbuffer-name1 buffer-name2 ,DATALINKSshared-frame
temptable-name
shared-workfile LIKE database. table database. table fieldWORKFILE TEMPTABLE table BY expressionFOR EACH OPEN QUERY char-string max-length justificationtranslatable FORMAT SUBSCRIBE6 class-name: event-name (exp)class-name: handler-name,parameter1 , parameter2, class-name: event-name (exp) ALLclass-name: handler-name,parameter1 , parameter2, database. table fieldDATA-MEMBERWORKFILE TEMPTABLEvariableSHAREDPUBLIC-DATA-MEMBER
class-name:data-member-nameINHERITED-DATA-MEMBER
class-name:data-member-namePUBLIC-PROPERTY
class-name:property-nameINHERITED-PROPERTY
class-name:property-namesequence-name SEQUENCE
This is the syntax for data-member-name:
variable-name dataset-name table fieldThis is the syntax for invocation-parameter:
INPUT-OUTPUT OUTPUTINPUTdata-type EXTENT constantTABLE temp-table-nameTABLE-HANDLEDATASET dataset-nameDATASET-HANDLETABLE-REFERENCEDATASET-REFERENCERUNTYPE
PUBLIC-DATA-MEMBER indicates that a line of code in a client of a class references a class public data member through an object reference. For example: localvar = MyInstance:PubMember. Properties are treated similarly.
In the CLASS entry, INHERITS inherited-class-name indicates the immediate super class of the class, if any exists. If the super class inherits from one or more classes, the names of these classes will appear following the name of the immediate super class of the compiled class. Each inherited class name will be separated from the preceding one by a space.
If a class has a super class but does not explicitly execute the SUPER statement in its constructor, the ABL compiler adds an implicit SUPER invocation to the r-code. When this happens, there will be an INVOKE entry generated for the implicit SUPER invocation. This entry indicates that the name of the method being invoked is super-class-type-name:class-name (the constructor name). Instead of a line number, the entry will use the label IMPLICIT.
Note that field for REFERENCE is optional. It will not appear if the corresponding line of code is either VALIDATE temp-table or RELEASE temp-table.Table 17 and the accompanying documentation in the XREF option section describes the XREF type and XREF information returned by either the XREF or the XREF-XML options. When you use XREF-XML, the XREF type is assigned to the Reference-type attribute. However, XREF information can be assigned to a number of XML elements including the Object-identifier attribute.For compiling several procedures and classes in a single compile statement, supply a directory for the XREF-XML option. The XREF-XML option uses this directory and a standard naming convention to capture the cross-reference information from multiple procedures and classes in separate files. Contrast this with the APPEND mode used by the XREF option.When a directory is supplied, the compiler takes the root name of the procedure or class being compiled and creates a cross-reference file with this name and a .xref.xml file extension (sourcefilename.xref.xml). It stores it in the directory path specified, creating any necessary subdirectories that do not exist. If the main directory specified does not exist, then an error is raised.If the filename supplied to the compiler begins with a relative path, then the directory name supplied to the XREF-XML option will include that relative path. For example, suppose your Unix PROPATH is /projectA/source and you run this COMPILE statement:
COMPILE test/procedureA.p XREF-XML /projectA/xrefThe COMPILE statement will look for the source file /projectA/source/test/procedureA.p and place the XREF-XML output in /projectA/xref/test/procedureA.xref.xml (if the source file successfully compiles).You may want to check for possible filename collisions before using this option. For example, if you have myCode.p and myCode.cls, both will use the myCode.xref.xml output file, destroying some of your cross-reference information.When you use the VALUE option to provide a filename or directory path, if VALUE returns the empty string or the Unknown value (?), then the compiler ignores the XREF-XML option.The XML Schema used with XREF-XML output files is stored in the following location: $DLC/properties/schemas/xrefdxxxx.xsd. The XXXX portion of the file name indicates the version number of the file.
Note: Writes cross‑reference string information between procedures and ABL objects, or between class definition files and ABL objects, to the file sxreffile or VALUE ( expression ). If expression evaluates to the Unknown value (?), ABL ignores the STRING-XREF option.
String Xref Version x.y source-file code-pageThe x.y is a major.minor version number, where a major version change implies a formatting change that will not be backward compatible with older versions of TranManII. The source-file is the name of the file from which the strings are extracted. The code-page is the code page with which the file was written.
line‑number object‑name string max‑length string‑justification statement‑type detail‑infoThe line‑number is the same as line‑number in the standard XREF file. The object‑name is the name of the object with which the string is associated. The max‑length and string‑justification come from the string attribute (either explicit or implicit) and reflect the attributes applied to the string as it is entered into the text segment.The statement‑type describes the type of statement in which the string appears. Only one statement type appears in a given string’s output line. The values in the following table are possible:
The detail‑info is one or more detail tags that specify more specifically where the string appears in the statement. The values in the following table are possible:
Table 18 shows the valid combinations of statement types and detail tags.
Identifies which language segments to include in the compiled r‑code. The language-list is a colon‑separated list of language names used to generate each text segment. If you specify VALUE ( expression ), the expression must evaluate to a comma‑separated list of language names. If expression evaluates to the Unknown value (?), then ABL ignores the LANGUAGES option.
COMPILE myfile.p LANGUAGES(French-Canadian:French:English,Portuguese:Spanish,New-York:American:English).If you use an expression to specify language-list, you must use the VALUE option. For example:
COMPILE myfile.p LANGUAGES (VALUE(char-var))./* char-var = "French-Canadian:French:English,Portuguese:Spanish,New-York:American:English" */This example generates four text segments: French‑Canadian, Portuguese, New‑York, and the unnamed (default) text segment. The first language name in each language-list argument designates the name of the text segment and specifies the first language that the compiler looks up in the translation database. As a result, it is possible to create a text segment whose name has no relationship to the languages it is composed of. For example, the following argument creates a text segment named BABEL:
LANGUAGES(BABEL:French:Spanish:Italian:German)TEXT-SEG-GROW = growth-factor
New-length =
Actual-length * ( 1 + ( growth-factor/100 * ( table-value/100 ) ) )
New-length is the new string length.
Actual-length is the actual string length.
growth-factor is the value specified with the TEXT-SEG-GROW option.
table-value is the appropriate percentage from the following table:
For example, if you have a text string that is 25 characters and you specify a growth-factor of 50, ABL applies the formula as follows and defines the New-length as 35:
New-length = 25 * ( 1 + (80/100 * (50/100)) )
Writes the debug listing to the file debugfile or VALUE ( expression ). If expression evaluates to the Unknown value (?), then ABL ignores the DEBUG-LIST option. The debugfile consists of a line‑numbered listing of the procedure with the text of all preprocessor include files, names, and parameters inserted. In Windows, the filename cannot contain characters outside of the non-Unicode code page.Preprocesses the procedure or class definition file and writes the preprocessed source code to the file preprocessfile or VALUE ( expression ). If expression evaluates to the Unknown value (?), ABL ignores the PREPROCESS option. The preprocessfile is a text file that contains a final version of your source code after all include files have been inserted and all text substitutions have been performed. In Windows, the filename cannot contain characters outside of the non-Unicode code page.V6FRAME = logical-expression USE-REVVIDEO USE-UNDERLINEIf you specify a logical-expression, its value determines whether the V6 compile option is activated. If the logical-expression is evaluated to the Unknown value (?), a run‑time error occurs.For more information on the environment for an ABL session, see OpenEdge Deployment: Managing ABL Applications.MIN-SIZE = logical-expressionIf you specify a logical-expression, its value determines whether the MIN-SIZE option is activated (TRUE) or not (FALSE). If the logical-expression evaluates to the Unknown value (?), a run‑time error occurs. The default value is FALSE.GENERATE-MD5 = logical-expressionIf you specify a logical-expression, its value determines whether the GENERATE-MD5 option is activated (TRUE) or not (FALSE). The default value is TRUE.You can read the MD5-VALUE attribute on the RCODE-INFO system handle to determine the MD5 value for a procedure or class.In this procedure, ABL compiles the ord-ent procedure, produces an r‑code file, ord-ent.r, that can be used across ABL sessions, and saves the r‑code file in the current directory:
COMPILE ord-ent SAVE.
Note: The sample procedures supplied with ABL do not include the ord-ent procedure.You can save the r‑code file in a different directory by using the SAVE INTO phrase. For example, to save an r‑code file in /usr/sources on a UNIX system, enter this command:
COMPILE ord-ent SAVE INTO /usr/sources.
FOR EACH Customer NO-LOCK:{r-fcust.i}{r-dcust.i}END.Suppose you use the following COMPILE statement to compile the r-incl.p procedure:
COMPILE r-incl.p SAVE LISTING r-incl.lis XREF r-incl.xrfDEBUG-LIST r-incl.dbg.This sample output is not an exact copy of the r-incl.lis file.
1. {} — The level of the include file
2. Line — The line number in the file
3. Blk — The number of the block
Line — The line number where the block starts
Blk. Type — The type of block (Procedure, DO, FOR EACH, REPEAT)
Tran — Whether the block is a transaction block
Blk. Label — The label of the block
Buffers — The name of the record buffer scoped to the block
Frames — The name of the frame scoped to the blockThis is the cross-reference file r-incl.xrf:Each line in the xref file specifies the procedure, line number, access type, and access information. The first line in the xref file contains the COMPILE access type directive and the name of the procedure exactly as it appears in the COMPILE statement. See Table 17 for a list of the values that follow a particular access type (for example, table and index after SEARCH).If you modified r-comlis.p to use the XREF-XML option instead of XREF, your cross reference file would be named r-comlis.xref.xml. The structured formatting of XML would use many more lines to display the same information on one line of standard XREF output. Here is a small snippet of that file:This is the debug listing r-incl.dbg:
INTERFACE interface-name,,,,
INTERFACE interface-name,INHERITS acme.inventory.IWarehouse(acme.inventory.IStoreRoom acme.inventory.IShelf),,,,
If you want all record retrieval statements in a procedure to default to NO-LOCK, you must compile the procedure in an ABL session started with the No Lock (-NL) startup parameter. For more information on record locking, see OpenEdge Getting Started: ABL Essentials. For more information on the No Lock (-NL) startup parameter, see OpenEdge Deployment: Startup Command and Parameter Reference.
Two additional startup parameters are available that can affect the behavior of the COMPILE statement: Compile Warning List (-cwl) and Keyword Forget List (-k). The Compile Warning List option lets you specify a set of ABL statements that trigger compile-time warnings if they are found in the source code. The Keyword Forget List option lets you disable specified keywords, allowing you to compile code in which those keywords occur as ABL user-defined element names, such as table, field, variable, and procedure names. For more information about these startup parameters, see OpenEdge Deployment: Startup Command and Parameter Reference.
The value of the PROPATH environment variable defines the list of directories (path) to use when searching for a procedure.
On UNIX, you define the PROPATH variable in a startup script or in your .profile file. In Windows, you can define your PROPATH in the Registry or in an initialization file. You can also define the PROPATH interactively at the operating system level.In addition to any directories you define for PROPATH, ABL searches the directory containing the ABL system software. If you do not define a value for PROPATH, ABL searches your working directory by default.
To locate the source file that you name in the COMPILE SAVE statement, ABL searches the first directory in PROPATH. If the source file is there, ABL compiles the source file and creates an r‑code file. On UNIX, this new r‑code file replaces any existing r‑code file. If errors occur during compilation, ABL does not produce an r‑code file and leaves existing r‑code files unchanged.
PROPATH="/pro1/source".COMPILE test/proc1.p SAVE INTO /pro1/obj.
COMPILE /pro1/obj/test/proc1.p SAVE INTO /usr/rcode.In the example, ABL saves the source file as /usr/rcode/proc1.r.When you use the SAVE INTO phrase to store compiled r-code files for one or more class definition files specified with a package, ABL creates a directory structure under the specified SAVE INTO directory that is consistent with the directory structure of the original source files relative to PROPATH (if the directory structure doesn’t already exist). That is, ABL creates a subdirectory under the specified SAVE INTO directory to match the original source directory for each class definition file in the hierarchy.For example, if the source for two class definition files in a class hierarchy reside in two different directories, such as dir1 and dir2, ABL creates two matching subdirectories named dir1 and dir2 under the specified SAVE INTO directory and stores the r-code files in their respective subdirectories.
To locate a file with the COMPILE statement (without the SAVE phrase), ABL searches the first directory in PROPATH for a usable r‑code file. A usable r‑code file must meet these criteria:
It must have the same cyclic redundancy check (CRC) value as any database tables it references, or the same time stamp if you are running with the Timestamp (-tstamp) parameter. When creating an r‑code file, ABL includes, as part of the r‑code file, either the CRC or the time stamp of the most recent change to the database schema that affects this procedure (for example, adding or deleting a field or index definition in a table that the procedure references).If there is no usable r‑code file, ABL searches the same directory in PROPATH for a source file. If the source file is there, ABL compiles it into the session compile file. If it is not there, ABL continues on to the next directory in PROPATH, searching for an r‑code file, then for a source file.
A WHOLE-INDEX search reported for a table occurs when an entire index is used to search the table. (That is, the bracket used by the query to search the table spans the entire index.) This can occur either when no selection criteria are specified to limit the range of index keys searched (that is, to bracket a subset of the index) or when there is no appropriate index available to optimize the selection criteria. For example, the following queries on Customer table of the sports2000 database both result in WHOLE-INDEX searches. The first query uses the Name index to search the entire table, returning every record in Name order. The second query uses the primary index to search the entire table because there is no index provided for the Balance field to limit the search.
FOR EACH Customer NO-LOCK USE-INDEX Name:DISPLAY Customer.END.FOR EACH Customer NO-LOCK WHERE Customer.Balance < 10000AND Customer.Balance > 5000:DISPLAY Customer.END.On the other hand, the following queries do not result in WHOLE-INDEX searches because the selection criteria directly limit the range of Name and CustNum index keys (respectively) to be searched:COMPILER system handle, NEW function (classes), RUN statement, Compile Warning List (-cwl), Keyword Forget List (-k), and No Lock (-NL) startup parameters (in OpenEdge Deployment: Startup Command and Parameter Reference)
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |