Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
RUN, or its equivalent shorthand ! (often spoken as Bang!), allows Visual FoxPro to run other programs. In the Windows version, you can access both Windows and DOS programs.
RUN | ! [ /nFreeMemory [K] ] ProgramName && DOS version
RUN | ! [Options] WinProgName && Windows version
Parameter |
Value |
Meaning |
nFreeMemory |
Numeric |
States the amount of memory required in kilobytes. FoxPro for DOS attempts to clear out this amount before invoking the specified program. |
ProgramName |
Name |
The name of the DOS program for FoxPro for DOS to run. |
Options |
Omitted |
Indicates that Visual FoxPro should start the specified program within a DOS box. |
/N or /N1 |
Means "NOWAIT," indicating that this is a Windows program. These settings run the Windows program, making the application active, running it in its "normal" size. "Normal" depends on the application. Many applications store the position they were in when they were last closed, and restore this setting under this "normal" condition. Others always open maximized, minimized, or somewhere in between. |
|
/N2 |
Runs the Windows program as the active application, but minimized. |
|
/N3 |
Runs the Windows program as the active application, in its maximized format. |
|
/N4 |
Runs the Windows program, restoring its normal window size, but does not activate it. |
|
/N7 |
Runs the Windows program, leaving it inactive and minimized. |
|
WinProgName |
Name |
The name of the program, either a DOS or Windows program, for Visual FoxPro for Windows to run. |
We break our rule in the diagram above in showing both the DOS and Windows versions of this command, but for an awfully good reason. Microsoft, and Fox Software before them, hopelessly mangled the explanation of these commands, and we’d like to clear the air. FoxPro for DOS, and FoxPro for DOS only, allows the specification of how much memory is required. The documentation folks chose to show it as /n, where n stood for the memory required in kilobytes. Then, some clever programmer decided that “/N” should be used as shorthand for “NOWAIT” for Windows programs only. This is just too much for anyone to get the first time through. If you need to run WordStar.Exe, an application requiring 320 kilobytes of memory, from your FoxPro/DOS application, you would issue either of these commands:
RUN /320 wordstar.exe
RUN /320K wordstar.exe
Visual FoxPro for Windows can run either DOS or Windows applications. If an application is run without the “NOWAIT” option, a DOS application is assumed. If a file extension is not specified, Visual FoxPro first looks for a file with the same program name and the extension PIF. A PIF, or Program Information File, dictates several characteristics of how an application should run. We won’t drag you through all the details—check out the Windows manuals or some of the better books in our bibliography for all the gory stuff. If a PIF cannot be found, Visual FoxPro runs FoxRun.PIF, normally located in the \VFP directory, or uses the default settings if this file cannot be found. It is FOXRUN.PIF that makes all of your DOS commands hang around, and your FoxPro session appear that it is locked up, but your alternative is to have your DIR or MEM commands appear and disappear too quickly to be seen. Consider making custom PIFs for commands you use often, and make sure to include them with your application if it needs to be distributed to others.
Running Windows programs is a pretty straightforward process. Select whether you would like the application you are running to take over the visual display and become active, or perhaps sit in the background, and set your /N settings appropriately. We often use /N7 to start applications we are going to converse with from FoxPro, using either Dynamic Data Exchange or Automation.
* Start Excel in the background, minimized
RUN /N7 EXCEL.EXE