Compile ... Save Into ... No-error

Anika

New Member
Hi,

Does anybody know something about the use of NO-ERROR in combination with COMPILE?

If I want to compile a file, but the target-directory doesn't exist, Progress shows an error-message. However, if I add NO-ERROR and use ERROR-STATUS, no error-message appears and ERROR-STATUS:ERROR is "no".

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
/* example */
DEFINE VARIABLE i AS INTEGER.

COMPILE test.p SAVE INTO "c:\test\" NO-ERROR.
/* show error-status */
MESSAGE ERROR-STATUS:ERROR
VIEW-AS ALERT-BOX INFO BUTTONS OK.
IF ERROR-STATUS:ERROR THEN
DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE ERROR-STATUS:GET-MESSAGE(i)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
[/code]

Any suggestions?

Anika
 

rich_t

New Member
Hi,

To test for a valid directory or file use the following code:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
ASSIGN FILE-INFO:FILE-NAME="&lt;dir name&gt;".

IF FILE-INFO:FILE-TYPE MATCHES "*D*"
THEN DO:

END. /* is a valid directory */

ELSE IF FILE-INFO:FILE-TYPE NE ?:

END. /* not a directory, just a file */

ELSE DO:

END. /* not a dir or a file */
[/code]

Basically, check out FILE-INFO in your help pages.

Hope this helps.
Rich
 

Chris Kelleher

Administrator
Staff member
Anika-

You actually need to check the ERROR and WARNING attributes on the COMPILER handle. Try this:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
/* example */
DEFINE VARIABLE iError AS INTEGER NO-UNDO.
DEFINE VARIABLE cFilename AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDirectory AS CHARACTER NO-UNDO.

ASSIGN
cFilename = "test.p"
cDirectory = "c:\test\".

FILE-INFO:FILE-NAME = cDirectory.

IF INDEX(FILE-INFO:FILE-TYPE,"D") EQ ? THEN
DO:
MESSAGE cDirectory "is not a valid directory name"
VIEW-AS ALERT-BOX ERROR.
RETURN.
END.

COMPILE VALUE(cFilename) SAVE INTO VALUE(cDirectory) NO-ERROR.

IF COMPILER:ERROR THEN
DO iError = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE "Complier Error:"
ERROR-STATUS:GET-MESSAGE(iError)
"in file" COMPILER:FILENAME
"at line" COMPILER:ERROR-ROW
"column" COMPILER:ERROR-COL
VIEW-AS ALERT-BOX ERROR.
END.

ELSE
IF COMPILER:WARNING THEN
DO iError = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE "Complier Warning:" ERROR-STATUS:GET-MESSAGE(iError)
VIEW-AS ALERT-BOX WARNING.
END.

ELSE
MESSAGE "Compiled Ok"
VIEW-AS ALERT-BOX INFORMATION.


[/code]

HTH.

-Chris

------------------
Chris Schreiber
ProgressTalk.com Manager
chris@fast4gl.com
 
Top