There have been alternatives suggested over time. Parameterized Macro Definitions (ugh, what an ugly name!) offer a new approach to this problem, a new simpler way to implement the solution, and a mechanism for creating an unlimited number of other definitions.
First an example:
Suppose you had a cursor (or table) with an alias of SomeName, and you wanted to insert into your method code the list of all fields in SomeName. With PMDs, you would enter:
and then press the associated hotkey. The odd -looking text beginning with ## is then replaced with the list of fields from the cursor.
Select ##Flds SomeName
So, what is going on?
- ## is the marker for the beginning of the PMD.
- Flds is the PMD keyword (case-insensitive)
- SomeName is the parameter which will be passed along to the sub-routine for processing
|## Flds FileName||Inserts the list of all fields from FileName, one per line, as would be used by SQL-SELECT. Qualifiers may be added later, to allow for searching for the file (if not open) and to insert an alias before each field name|
|## From FileName, ID=OtherFile.ID, etc.||Inserts a FROM statement (for SQL-Select) and related JOIN statements; e.g., From Filename Join OtherFile on Filename.ID = OtherFile.ID|
|## LS FileName||Creates a new window to display the structure for Filename|
|## ?||Creates a new window to to display a list of all PMDs (much like this list|
Create your own PMDs
The neatest thing about this is that you can create new PMDs very simply, by adding creating new Plug-Ins. The code is very easy to write (the PRG is passed the keyword and parameter, and returns the text to be inserted).
Furthermore, the code for each of the PMDs to be included here will be available in the Sample Plug-Ins folder. You will see there is precious little code, and it's not very sophisticated at all. You may even want to modify it (for instance, if you don't like the way the field names are created for ## Flds.)
All that needs to be done is to create a PRG named HASH<something>.PRG into the the Plug-Ins folder, follow the structure and comments from the samples, and you can create your own PMDs, working on their own keywords.
This is not quite ready for use (unfortunately). Look for release 6.11.003 soon. Possibly this weekend if all goes well.
Many thanks to Tore Bleken on this one. He posted the original suggestion and through a succession of emails we arrived at the the design described above. Thanks, Tore!