8

The LA Fox Developer Newsletter
December 2000
Command Manager
by Jeff Bowman

Here’s a handy little utility you can use when you get tired of
typing all of those lengthy ‘MODIFY CLASS’ and ‘DO FORM’
commands in your Command Window.

The idea was borne of frustration with either manually typing
out cumbersome commands, plus path and filename, or of
maintaining an awkward ON KEY LABEL list. The list
approach is certainly easier than typing the commands, or even
navigating the Open File dialog, but you still have to maintain a
program file. In order to change an OKL, you must laboriously
copy-and-paste the command text (after wrangling the path and
filename in the first place), and rerun the program each time
you want to update the list. You’ll also probably keep running
out of available OKLs that make sense and are consistent with
what you’re working on at the time.

Command Manager solves all that. Assign an OKL in your
startup program to run the form (e.g., ‘ON KEY LABEL F5 DO
FORM c:\tools\manager’), and you’ve now extended that one
OKL to up to twenty MODIFY and/or RUN commands.

To use Command Manager, first load the filename you want to
process into one of the fields on the form. You do this by
clicking the ellipsis button to the right of the desired field.
Navigate to the file of interest and click Select (if you’ve chosen
a class library, you’ll be prompted to select a class from that
library). You can now process the command by tapping the
desired number on your keyboard, and then either ‘M’ or ‘R’ to
modify or run the specified file. You’ll notice that certain file
types, when selected, disable the ‘Run’ functionality; this is
because that file type cannot be run from the VFP Command
Window. All file types, of course, may be modified.

I hope you find Command Manager to be of use to you. I
finished it only recently, and therefore have used it only a few
times, but even those few times have been enough to make me
glad I have it. Some planned features are the ability to pass
parameters with a ‘Run’ command, pasting of the executed
command into the VFP Command Window, and allowing
execution of other VFP code before processing a command.

You may download Command Manager or any of several Visual
FoxPro-related utilities and code samples from
http://www.jeffbowman.com/. Send any comments or bug
reports to jbowman©jeffbowman.com, and if you would like to
be added to a mailing list to stay informed of updates on any
code that you download from the site, send an email to that
effect, specifying your interest.

Happy coding!


(Con’t, page 9)
Detecting DCOM Installation
Under VFP6
VFP6 needs DCOM to be properly installed if you disable the
VFP main windows through CON FIG.FPW; at termination, VFP
will cause a C0000005 error. There are other situations involving
ON SHUTDOWN which may show some of the same symp-
toms if DCOM isn’t there.

DCOM can get put on a system in several ways; under WinNT.
installation of SP3 or SP4 should add DCOM support, as would
installation of 1E4. Win98 should always have DCOM support
loaded unless by some quirk of fate 1E4 misinistalled. Win95
systems can add DCOM by installing lE4, or by installing the
support either from the DCOM95 version 1.2 support file (a self-
extracting .EXE) or the DCOM98.EXE found on the Visual
Studio distribution.

The C0000005 error only occurs if SCREEN=OFF and you
subsequently make either the VFP main screen visible
(_screen.visible = .t.) or activate a top-level form. You can detect
that DCOM is missing and shut down before anything happens
using the Registry class in the FFC and MESSAGEBOXO to
display a message without making a form visible:

#INCLUDE REGISTRY.H
#DEFINE DCOMKEYSTRING 'SOFTWARE\Microsoft\OLE'
*
note the preceding line was corrected to remove the leading “V
#DEFINE ENABLEDCOMKEY ‘EnabIeDCOM’
SET CLASSLIB TO REGIsTRY.vcx
oReg=cREATEOBJ(’registry’)
LOCAL IFoundDCOM
IFoundDCOM = .F.
IF
oReg.OpenKey(DcOMKEYSTRING,HKEY_LOcAL_MAcHINE,.F.) = 0
LOCAL cValue
cValue
IF
oReg.GetKeyValue(ENABLEDCOMKEY,~cVaIue) =0
IFoundDcOM =! EMPTY(cValue)
ENDIF
ENDIF
IF
I IFoundDCOM
MESSAGEBOX(’DCOM not present on system. Please install it
before running this application’,
16,;
‘Missing Windows Component’)
QUIT
ENDIF


Don’t forget...

DevConnections 2001
http://www.devconnections.com
Page 8

8