![]() |
![]() |
8 |
![]() |
The LA Fox Develooer Newsletter
July 1997
An Alternative to Macro Files
by Todd Landrum, Rocky Mountain
Fox
User Group
THERE IS AN EASIER WAY
Using macro keys are a great way to make your development
life easier. You can set up macro keys to quickly execute the
commands you type over and over again in during the day.
As an example, you might use a macro key to run a project.
use FlO for this and the macro command is:
{Ctrl+F2}Do MyApp{Enter)
The {Ctrl+F2} makes the command window active, the DO
command is entered, and {Enter} runs the command. A couple
other macro keys I use are:
Fl 1 {Ctrl+F2}build app MyApp.app from MyApp.pjx{Enter}
F12: {Ctrl+F2}modi proj MyApp{Enter}
These macros work great for me, they help me work faster, and
I manage to finish the project on time and on budget. Time for
project #2.
I want the same macro keys for this project, but the name of the
project file in this case ends up being MyApp2. No problem. 1
copy the macro file from project 1, edit the three commands and
away I go.
Now I’m on to project 3, MyApp3. I copy the macro file, edit the
three commands and away I go. Now comes project 4... and
project 5... and project 6....
During project 6, I get tired of pressing Ctrl+F2 to bring up the
command window. I want an easier way to do this. No problem.
I create a new F2 macro key that does the {Ctrl+F2} command
for me.
Now I go back to project 2 to do some additional work. I press
my handy F2 macro key and nothing happens! Suddenly, I have
a problem. I created the F2 key in the macro file for project 6
but I didn’t create it in the macro file for project 2. Or for project
l.Orforproject3... or4... or5.
If I want the F2 key in every project, I am going to have to go
back through projects 1, 2, 3, 4, and 5 and add that macro. That
doesn’t seem like an efficient use of time and, tomorrow, I’ll
come up with another macro key I want in every project. I’ll have
to go change every macro file again.
What I need is some way to define global macros that will be
available in all projects and local macros that are available in a
specific project. This is the problem I faced and here is the
solution I came up with.
Start by creating a global macro file. This is the macro file you
are going to use for every project. It is only one file. You never
copy it. Instead of placing specific commands with the macro
keys, you enter a generic command. These commands would
look as follows:
F2: {CtrI+F2}Do MacroL with ‘F2’{Enter}
Fl 0: {CtrI+F2}Do MacroL with ‘Fl O’{Enter}
Fl 1: {CtrI+F2}Do MacroL with ‘Fl 1 ‘{Enter}
F12: {Ctrl+F2}Do MacroL with ‘F12’{Enter}.
Each of these macro keys calls a program named MacroL and
passes the key being pressed. MacroL is going to be our local
macro keys program and it would reside in the directory with the
project. The layout of this program is:
PARAMETER IMacro
DO CASE
CASE IMacro
=
‘FlO’
Keyboard “{ctrl+F2)do MyApp{Enter}”
CASE IMacro
=
‘F11’
build app MyApp.app from MyApp.pjx
CASE Macro
=
‘F12’
Keyboard “{Ctrl+F2}modi proj MyApp{Enter}”
OTHERWSE
do MacroG with Macro
ENDCASE
RETURN
You can see that this program handles the FlO,
Eli,
and F12
keys. If you have any other macro keys that are specific to the
project, you add them to MacroL.
Notice that the F2 key is not processed in MacroL. If F2 is
passed as the parameter to MacroL it falls into the 0TH ER-
WISE clause and MacroG is called.
MacroG is our global macro program. You’d only have one copy
of this program located somewhere in your path. Mine is in the
Foxpro directory. Any commands not processed by MacroL are
processed by MacroG. The layout of this program is:
PARAMETER IMacro
DO CASE
CASE Macro
=
‘F2’
keyboard “{CtrI+F2}”
OTHERWISE
WAIT ‘Unknown macro key:
+
Macro WINDOW
ENDCASE
RETURN
This program handles all the commands that MacroL could not
process. It also gives a warning message if it doesn’t know how
(Con’t, page 9)
|
![]() |
![]() |
8 |
![]() |