Windows AppBuilder
In the Windows Appbuilder the Application Compiler is found in the Tools Menu.
Procedure Editor (Linux - pro
or Windows pro.exe
In the Procedure Editor (both Linux and Windows) the Compiler if found in the Tools menu.
Application Compiler
Regardless of OS the functionality of the compiler is the same. You can add directories and/or files and compile them.
Main settings (more below):
Options:
The main menu choices:
Settings
XREF
. Useful for debugging, checking index usage etc.xcode
insert the key here.Basic usage
The compile statement lets you compile programs in Progress ABL:
Basic usage:
COMPILE hello-world.p SAVE.
With a variable:
DEFINE VARIABLE prog AS CHARACTER NO-UNDO.
prog = "hello.p".
COMPILE VALUE(prog) SAVE.
There are several options to the COMPILE
-statement:
SAVE
states that the .r-code should be saved for future use.
COMPILE hello-world.p SAVE.
SAVE INTO dir OR SAVE INTO VALUE(dir-variable)
saves the r-code in the specified directory:
COMPILE hello-world.p SAVE INTO /usr/sources.
LISTING file
. Creates a listing file containing debug information regarding blocks, includes etc.
COMPILE program.p SAVE LISTING c:\temp\listing.txt.
Listing has a couple of options for appending files, page-size and page-width:
APPEND PAGE-SIZE num PAGE-WIDTH num
XREF xreffile
will save a compiler xref file containing information about string and index usage etc. You can also APPEND
this one.
COMPILE checkFile.p SAVE XREF c:\directory\xref-file.txt.
XREF-XML xreffile-or-dir
will do the same thing as XREF
but save the file in an xml-format instead. If you use a directory the xref-file will be named programname.xref.xml
.
COMPILE file.p SAVE XREF c:\temp\.
NO-ERROR
will supress any errors from stopping your program.
COMPILE program SAVE NO-ERROR.
DEBUG-LIST file
generates a debug file with line numbers.
COMPILE checkFile.p SAVE DEBUG-LIST c:\temp\debug.txt.
PREPROCESS file
will first translate all preprocessors and then create a new .p-file with the code prior to compiling.
COMPILE checkFile.p SAVE PREPROCESS c:\temp\PREPROC.txt.
XCODE key
will compile an encrypted source code with key
as key. You cannot use XCODE with the XREF, XREF-XML, STRING-XREF, or LISTING options together.
COMPILE program.p SAVE XCODE myKey.
You can combine several options:
COMPILE prog.p SAVE INTO /usr/r-code XREF /usr/xrefs/xref.txt APPEND LISTING /usr/listings.txt APPEND NO-ERROR.
The COMPILER
system handle let's you look at information regarding a recent compile.
Assuming ok-program.p
is a program without any errors or warning:
COMPILE ok-program.p SAVE NO-ERROR.
DEFINE VARIABLE iError AS INTEGER NO-UNDO.
MESSAGE
"Errors: " COMPILER:ERROR SKIP
"Warnings: " COMPILER:WARNING SKIP
"Messages: " COMPILER:NUM-MESSAGES
VIEW-AS ALERT-BOX INFORMATION.
This will procude:
Compiling a program with a warning:
/* program-with-warning.p */
DEFINE VARIABLE c AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
c = "hello".
DISPLAY c.
//This RETURN makes the program exit here and the code below unreachable.
RETURN.
IF TRUE THEN DO:
i = 10.
END.
Compiling the program:
COMPILE program-with-warning.p SAVE.
DEFINE VARIABLE iError AS INTEGER NO-UNDO.
MESSAGE
"Errors: " COMPILER:ERROR SKIP
"Warnings: " COMPILER:WARNING SKIP
"Messages: " COMPILER:NUM-MESSAGES
VIEW-AS ALERT-BOX INFORMATION.
DO iError = 1 TO COMPILER:NUM-MESSAGES:
DISPLAY
COMPILER:GET-FILE-NAME(iError) LABEL "Filename" FORMAT "x(20)"
COMPILER:GET-MESSAGE(iError) LABEL "Message" FORMAT "x(50)"
COMPILER:GET-NUMBER(iError) LABEL "Msg#"
COMPILER:GET-ERROR-COLUMN(iError) LABEL "Column"
COMPILER:GET-ERROR-ROW(iError) LABEL "Row"
WITH FRAME fr1 SIDE-LABELS 1 COLUMNS.
END.
Result:
Compiling a program with an error
DEFINE VARIABLE c AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
c = "hello".
DISPLAY c.
//Casting should be required below...
IF TRUE THEN DO:
i = c.
END.
Compiling the program:
//Use no-errors to supress any error messages from interrupting us.
COMPILE c:\temp\program-with-error.p SAVE NO-ERROR.
DEFINE VARIABLE iError AS INTEGER NO-UNDO.
MESSAGE
"Errors: " COMPILER:ERROR SKIP
"Warnings: " COMPILER:WARNING SKIP
"Messages: " COMPILER:NUM-MESSAGES
VIEW-AS ALERT-BOX INFORMATION.
DO iError = 1 TO COMPILER:NUM-MESSAGES:
DISPLAY
COMPILER:GET-FILE-NAME(iError) LABEL "Filename" FORMAT "x(20)"
COMPILER:GET-MESSAGE(iError) LABEL "Message" FORMAT "x(50)"
COMPILER:GET-NUMBER(iError) LABEL "Msg#"
COMPILER:GET-ERROR-COLUMN(iError) LABEL "Column"
COMPILER:GET-ERROR-ROW(iError) LABEL "Row"
WITH FRAME fr1 SIDE-LABELS 1 COLUMNS 20 DOWN.
DOWN WITH FRAME fr1.
END.
Result, there's almost always two errors per error. "Could not understand" is followed by the actual error: