Saturday, November 27, 2010

PEM Editor tip: Creating LOCAL statements

The Create LOCAL Declarations function of PEM Editor is a huge timesaver. It traverses the currently open method and creates a LOCAL statement for all variables that have been assigned there.

It can be accessed in one of three ways:
  • From the 'PEM Editor' menu item in the VFP Main Menu
  • By using the hot key you have assigned to it (click the Preferences button, select the Hot Keys page of the Preferences dialog, select the BeautifyX & Locals subpage, and remove the “*” at the start of the hot key for Create LOCAL Declarations or enter the key you want to it to be defined as.)
  • By including it automatically when you run BeautifyX (same LOCALs subpage as above, but select 'Create LOCALs as part of BeautifyX')
The LOCALs subpage of the BeautifyX page of the Preferences dialog even allows you to configure how the LOCAL statement looks.

For even more control, copy CreateLocalStatements.PRG from Sample Plug-Ins to Live Plug-Ins; that program allows you to code how the statement should look. For example, some users like the variables to appear in LOCAL in the order they appear in the program, while the default behavior of CreateLocalStatements.PRG is to sort them alphabetically. Fortunately, that’s easy to change: comment out this line:

Asort (laLocals, 1, -1, 0, 0)

No comments:

Post a Comment