LPEX - The 'Other' Programmer's Editor

By Douglas Clark

LPEX may be one of the best kept secrets in the OS/2 world. While EPM gets all the glory as the editor of choice on OS/2, its successor LPEX gets no respect. This is too bad because in many ways LPEX is a better editor than EPM. This article is a short look at LPEX, and how it compares with EPM.

Where to Find LPEX
LPEX is bundled as part of the VisualAge C++ products. In VAC V 3 the editor appears as a stand-alone application that could be integrated into the WorkFrame. In VAC v 4 the editor appears in the VAC IDE. In both products the editor can be started and run by itself by executing the file IBMCPP/BIN/lxpm.cmd where IBMCPP/ is the directory where VAC is installed. The editor also runs on Windows, and I guess in AIX, although I have never used AIX.

Both LPEX in VAC version 3 and in version 4 can be separated from the VAC package and run by itself if you have enough patience to find all the DLLs used by the editor.

LPEX - The Parsing Editor
LPEX gets its initials from the name "live parsing editor." It parses the lines you type, as your type them, and displays syntax errors immediately; you don't have to run the source code through the compiler or interpreter to catch simple syntax errors. This can be a huge time saver regardless of whether you are writing C code or REXX code. LPEX comes with "profiles" for C, C++, COBOL with and without embedded SQL, Fortran, JCL, Pascal, OS/2 .RC type files, and REXX to name a few.



Complex syntax errors, such as missing an ending bracket or END statement, are beyond the ability of the parser.

The parsing of the source file also allows the editor to offer some unique features, such as: the ability to find a function quickly in a file by hiding all the lines in the file except those that define or start functions, placing your cursor on the function you want, and then showing all the lines in the file.



Since the editor has parsed the source file you can use that intelligence to move forward or backward to the next/previous function or class in the file.

Other Features
LPEX has a number of other features that can help in writing code. The split view allows you to view two different files in the same window (handy for viewing the header file with a class definition while coding the methods in the CPP file), or it can load the same file into both views allowing you to see and work on different parts of the file at the same time.

LPEX also has a compare feature that will load two files up in side by side views and show the differences between the files.

Programming the Editor
LPEX uses two languages for writing macros: Rexx and C. The E language used by EPM is history.

The editor configuration can be modified by various "profile" files that are loaded at different events as the editor starts and as it loads a file. There are three types of profile files:
 * profinit.lxu:User profile that runs when the Editor is first initiated.
 * profsys.lxu:User profile that runs each time a new file is loaded into the Editor.
 * xxx.lxu:User-defined language profile that runs each time a file of type xxx is loaded into the Editor.
 * profile.lx:Version 3 only. Read after each file is loaded and used by the editor to store some configurations made from the menus.

The editor searches along the path defined by the environment variable CPPLPATH (version 3) or CPPLPATH4 (version 4) for macros and profile files.

The profile files contain REXX code and editor commands which can modify the appearance and function of the editor. The following is an example of a profile file I use for version 4 of LPEX, in this case profsys.lxu, which is read each time a file is loaded in the editor. In it I set the key mapping to what I am familiar with, which is also the same key mapping I use in EPM. This file also shows an example of changing the File Open icon on the tool bar so that it opens a standard File Dialog instead of the one normally used by LPEX.  /* profsys.lxu */ SET TOOLBAR.LP_OPENEDIT set toolbar.open BITMAP _2 2 macro openfile 'set blockdefaulttype rectangle' 'set action.f2 save' 'SET ACTION.BUTTON2DRAG  ;PRIMITIVE SETCURSOR ;BLOCK MARK ELEMENT' /* Function key assignments */ /* F1 = system help key */ 'SET ACCELERATOR.LP_SAVE F2'     /* save & continue */ 'SET ACCELERATOR.LP_CLOSEVIEW F3' /* quit, prompt if file has changed */ 'SET ACTION.F4 FILE'             /* save & quit */ 'SET ACTION.F5 LP_FINDCHANGE'    /* Find dialog */ 'SET ACCELERATOR.LP_LINE F6'    /* locate line dialog */ 'SET ACTION.F7 RENAME'           /* call the rename.lx macro */ 'SET ACTION.F8 DIALOG OPEN'      /* open a file  */ 'SET ACTION.F9 dup'              /* undo the last action */ /* F10 = system's switch to the action bar */ 'SET ACTION.F11 GODOC'           /* go to the previous file  */ 'SET ACTION.F12 GODOC NEXT'      /* go to the next file */ 'SET ACTION.C-DOWN mark set quickm'   /* set a quick mark */ 'SET ACTION.C-UP mark find quickm'    /* find the quick mark */ 'SET TABS EVERY 4'                    /* sets the tab for 4 spaces */ 'SET ACTION.C-L dialog element'       /* locate line */  The line SET TOOLBAR.LP_OPENEDIT removes the standard file open icon from the tool bar. The next line set toolbar.open BITMAP _2 2 macro openfile adds an icon (the same icon used by the "standard" open file) in the second position from the left, and when the toolbar button is clicked the macro openfile.lx is executed. That macro appears below.  /* Open File Dialog */ call RXFuncAdd "VRLoadFuncs", "VROBJ", "VRLoadFuncs" call VRLoadFuncs call RxFuncAdd 'SysIni','RexxUtil','SysIni' /* get the last path used/opened  from INI file SETTINGS.INI */ lastpath = sysini("D:\EDITOR_PROFILES\SETTINGS.INI","OPEN","Path") if (lastpath = 'ERROR:') then filemask = '*.*' else filemask = lastPath||'\*.*' files.0 = 0 rc = VRFileDialog('','LXPM Open File','O',fileMask,,,,'files.') if files.0 > 0 then do do i = 1 to files.0 'lx ' files.i end end /* save this path in the INI file  */ pos = lastpos('\',files.1,) if (pos > 0) then do lastPath = substr(files.1,1,pos-1) rc = sysini("D:\EDITOR_PROFILES\SETTINGS.INI","OPEN","Path",lastPath) end  The openfile.lx macro retrieves the last directory displayed in the File Dialog, opens the file dialog using that directory, and then opens each file in LPEX that was selected in the File Dialog. I am using the VRFileDialog function from VX-REXX to display a file dialog, mainly because it was handy. (The reasons I want to replace the LPEX file dialog are because the LPEX version is slightly broken, and because I want to use the XFILE dialog enhancer loaded on my system.)

Writing macros for LPEX is actually easier than for EPM because it uses pure Rexx, rather than the E language.

LPEX verses EPM
While I think LPEX is a better editor than EPM, I am not ready to retire EPM. In fact EPM is probably the one OS/2 application I use the most. There are still some areas in which EPM is better than LPEX. A comparison between the two is:
 * 1) LPEX parses each line of text as it is entered and reports syntax errors immediately, EPM does not.
 * 2) LPEX is bundled with VisualAge C++ and Visual COBOL and thus is not freely available; EPM is freely available, and has been bundled with OS/2 since version 2.0.
 * 3) LPEX runs on OS/2, Windows, and AIX; EPM only runs on OS/2.
 * 4) LPEX uses Rexx and C as macro languages; EPM uses Rexx, C, and its own E language for writing macros, and many things have to be done in E.
 * 5) Both editors has an API for C language interfacing.
 * 6) LPEX is almost entirely configurable through menus and dialog boxes; EPM needs to be recompiled for many configuration changes.
 * 7) EPM has a spell checker that can be integrated into the editor; LPEX does not.
 * 8) The EPM editor "engine" can be compiled into another application, providing powerful editing capabilities to your own applications. LPEX does not have that capability.
 * 9) EPM has a huge number of add-on packages and macros/commands freely available; LPEX has a much smaller number.
 * 10) LPEX has a number of very powerful, very valuable features built in to the editor such as split views and a compare facility. EPM does not.

Conclusion
If you have access to LPEX by owning one of the applications LPEX is bundled in, you ought to take a look at it. LPEX can be configured to work very similarly to EPM, making the transition between the two painless. Plus LPEX runs on Windows, for the occasions when you can't avoid working in the evil empire. In many ways LPEX is more powerful than EPM, which is what you would expect from EPM's successor.