Logo

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.

Type

This command is a lot like the DOS TYPE command, only smarter. It lets you display a text file on screen or send it to the printer or another file (though why you’d want to scroll one file to another is a mystery to us).

Usage

TYPE cFileName
    [ AUTO ] [ WRAP ]
    [ TO PRINTER [ PROMPT ] ]
    | [ TO FILE cOutputFile [ ADDITIVE ] ]
    [ NUMBER ]

Keyword

Meaning

AUTO

Turn on automatic indentation. Each paragraph is indented to the level of the first line of the paragraph. Use with WRAP.

WRAP

Turn on automatic word-wrapping.

TO PRINTER

Send the file to the printer.

PROMPT

Display the Windows Print dialog before printing.

TO FILE

Send the output to the named file.

ADDITIVE

Add to the named file instead of overwriting it.

NUMBER

Precede each line with a number.

AUTO needs to be used with WRAP. By itself, it doesn’t appear to do anything. Together, the result is pretty cool. Both AUTO and WRAP use the word-processing definition of a “paragraph”—everything up to a hard return. So, files containing hard returns (CHR(13) at the end of each line) either wrap badly or not at all, depending on the original line length. Wrapping is based on an 80-character line. We don’t see why TYPE doesn’t respect SET MEMOWIDTH, but it doesn’t.

TYPE can't handle long files that contain no returns unless you use WRAP. Without WRAP, they get cut off after 256 characters. Every version of FoxPro for Windows we tested showed the same bug, though it works properly in FoxPro for DOS.

If you specify AUTO WRAP NUMBER, be sure that none of the paragraphs begin with spaces. Lines in those paragraphs don't get numbered. We're not sure how much we care, since we can't see why you'd want to combine those options, but we figured we ought to tell you.

As with many commands that send output to a file, the ADDITIVE clause works but is undocumented.

Whether or not you specify TO PRINTER or TO FILE, the output of TYPE scrolls in the active window. Unfortunately, TYPE ignores the setting of SET CONSOLE, so there’s no direct way to prevent this. You can define and activate a window NOSHOW (or off-screen) to hide the output, but you shouldn’t have to.

When SET HEADING is ON, TYPE’s output includes a heading consisting of the filename, the date and a page number.

Example

TYPE README.TXT
TYPE BUGGY.PRG TO PRINT NUMBER

See Also

?, ??, ???, @…Say, FileToStr(), Low-Level File Functions, Set Alternate, Set Console, Set Heading, Set Printer, Set TextMerge