Progress 4GL ABL Check Syntax in Sublime Text

Progress 4GL ABL Check Syntax in Sublime Text

If you happen (or would like) to edit your Progress 4GL ABL programs with the excellent Sublime Text editor, you will loose the “Check syntax” feature of Progress OpenEdge Architect.

Here is how to get back this functionality in Sublime Text! Please follow the instructions on the GitHub page of our project, or read below.

Create a file named syntax.p with the following content:

/* Progress Check Syntax by Gabriel Hautclocq */
/* How to use it : C:\Progress\102B\bin\_progres.exe -1 -b -pf C:\Progress\102B\startup.pf -p C:\path\to\syntax.p -param "C:\program_to_check.p" */
 
DEFINE VARIABLE ch_prog AS CHARACTER NO-UNDO.
DEFINE VARIABLE ch_mess AS CHARACTER NO-UNDO.
DEFINE VARIABLE i       AS INTEGER   NO-UNDO.
 
/* Extracts the parameters */
ASSIGN ch_prog = ENTRY( 1, SESSION:PARAMETER ).
IF NUM-ENTRIES(SESSION:PARAMETER) >= 2 THEN DO :
  ASSIGN PROPATH = PROPATH + ":" + ENTRY( 2, SESSION:PARAMETER ).
END.
 
/* Compile without saving */
COMPILE VALUE( ch_prog ) SAVE=NO NO-ERROR.
 
/* If there are compilation messages */
IF COMPILER:NUM-MESSAGES > 0 THEN DO:
 
  ASSIGN ch_mess = "".
 
  /* For each messages */
  DO i = 1 TO COMPILER:NUM-MESSAGES:
 
    /* Generate an error line */
    ASSIGN ch_mess =
      SUBSTITUTE( "&1 File:'&2' Row:&3 Col:&4 Error:&5 Message:&6",
        IF COMPILER:WARNING = TRUE THEN "WARNING" ELSE "ERROR",
        COMPILER:GET-FILE-NAME  ( i ),
        COMPILER:GET-ROW        ( i ),
        COMPILER:GET-COLUMN     ( i ),
        COMPILER:GET-NUMBER     ( i ),
        COMPILER:GET-MESSAGE    ( i )
      )
    .
 
    /* display the message to the standard output */
    PUT UNFORMATTED ch_mess SKIP.
  END.
END.
ELSE DO :
 
  /* display to the standard output */
  PUT UNFORMATTED "SUCCESS: Syntax is Correct." SKIP.
END.
 
/* End of program */
QUIT.

Then you will need to make a build file for Sublime Text.  Create a file named “ABL.sublime-build” in “C:\Users\<your user>\AppData\Roaming\Sublime Text 3\Packages\User” with the following content:

{
  "shell_cmd": "C:\\Progress\\102B\\bin\\_progres.exe -1 -b -pf C:\\Progress\\102B\\startup.pf -p C:\\path\\to\\syntax.p -param \"$file\"",
  "file_regex": "^(?:ERROR|WARNING]) File:'(.+)' Row:([0-9]+) Col:([0-9]+) Error:[0-9]+ Message:(.*)$"
}

Bingo! Restart Sublime Text. Now you should be able to check the syntax using CTRL + B!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.