You can hit enter anywhere on the line in the command window

The Fox Command window maintains a history of prior commands. (A quick search of the source code logs shows I added this feature on June 19, 2000, then a quick look at my ShipIt Award (a little trophy/plaque from Microsoft which has stickers for each product and it’s release date) so that would be in VFP7.) This history is preserved across application shutdown.

The command window is a special instance of the VFP general purpose text editor, which means navigating around and editing text are the same. If you hit enter anywhere on a line, that (possibly modified) line is appended at the end of the command window, prior edits on all prior lines are reverted, and the appended text is executed.

Additionally, if you highlight multiple lines and hit enter, all of those lines are copied to the end and executed.

This multiple line feature can be a little misleading: they are executed as if in a procedure, which means any non-public declared variable will go out of scope.

For example, type these three lines into the command window

oXL=CREATEOBJECT("excel.application")

?oXL.Name

CLEAR ALL

Excel has been created, its name printed to the active form window (_screen by default), then released. Now highlight the first two lines and hit enter on them. Because they’re executed as if in a procedure, the “oXL” variable goes out of scope. Now try ?oXL.Name and it yields an error.

Because the command input and results output windows are separate,

If the text being appended to the end of the command window is the same as the current end text, then the append is skipped. That way, if you keep hitting up-arrow, enter to execute the same line over and over, there won’t be multiple entries in the history.

Other similar command window environments (like CMD.EXE or the Visual Studio command window) always keep the cursor on the bottom line. If you hit up arrow, the contents of the bottom line change to a prior line, but the cursor stays at the bottom. Try hitting F7 in a CMD.EXE prompt! Also try hitting F2 (copy up to the given char) and F3 (copy rest of line): this line editing functionality was also built into EdLin and many prior environments: I remember using these line editing features in 1971! (A feature I really like in CMD.EXE is hitting the TAB key, which does a partial filename match completion: see your registry: [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]

"CompletionChar"=dword:00000009

By default, the command window history is stored in the same place as your fox resource file (foxuser.dbf, which is HOME(7)+"command.prg" which is “c:\documents and settings\calvinh\application data\microsoft\visual foxpro 9\_command.prg”. That means other users who log into the machine will have a separate history.

You can right click on the command window and select “Clear” to clear the history.

Additionally, VFP respects the Recent Docs System Policy found in the registry at HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoRecentDocsHistory. The command history is also disabled if VFP is started via Automation:

oVFP=CREATEOBJECT("visualfoxpro.application")

oVFP.Visible=1

When the user performs an action via the VFP menus or dialogs, often the equivalent command is appended to the command window. For example, open the Data Session window (Window Menu-> Data Session). Choose the “Open” button and navigate to a DBF file.

This line was added to my command window:

USE d:\fox90\test\customer.dbf IN 0 SHARED

Because the Command Window is a subclass of a normal editor window, full drag/drop features also work in and out of the command window. That way, it’s easy to create a program from a series of interactively executed commands.

See also: Tools->Options->Dump out settings changed