MODIFY FORM

Run, !

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.

Usage

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.

Example

* Start Excel in the background, minimized RUN /N7 EXCEL.EXE

See Also

Configuration Files, DDEInitiate


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net