Writing the Window Contents to a File

The window image write function, wn_wr(), copies the character contents of the window image to a file. You can have wn_wr() write either the full window image, including borders and margins, or just the interior work area:

int wn_wr(filespec, dmode, image_part, wnp)
 
UCHAR *filespec;
/* Path (optional) and filename to copy to
*/
char *dmode;    
/* Mode of disk operation, "w", "a", or "p"
*/
int image_part;
/* image_part: PRINT_FULL or PRINT_INSIDE 
*/
WINDOWPTR wnp;
/* Pointer to a window structure
*/

For the filespec specify the name of the file to copy the window image to. The filespec can include the drive and path of the file. If the specified file does not exist, it is created.

Note: Because of the C convention of using the backslash as an escape character to introduce special characters (such as '\t' for tabs), use two backslashes in PCDOS path names (e.g., "c:\\temp\\screen.txt").

The dmode parameter specifies whether the file is to be opened in the "w" mode, which overwrites the contents of the specified file, or "a" mode, which appends the copied information to the existing information in the file. For UNIX and POSIX systems, you can specify "p" for dmode to open a pipe to the shell command specified as the filespec. These are the same arguments used in the fopen() call. See your compiler manual for more information.

The image_part parameter specifies what dimensions of the window you wish to write. Use PRINT_INSIDE to specify just the interior work area of the window, or PRINT_FULL to indicate the entire window including the border and the margins.

wn_up(ex_wnp);

v_st("Write some text in the window that you want saved.", ex_wnp);

wn_wr("windows.doc", "a", PRINT_FULL, ex_wnp);

Because wn_wr() copies the window image directly from the window's destination screen, the image will include children windows and even pieces of overlapping windows (if any exist). If this is not what you want, use sw_dest() before wn_wr() to isolate the window image. For more information about this, see the section on sw_dest() in Chapter 28, "Advanced Window Management."

When writing the window contents to the file, tabs are compressed based on the number of spaces between tab stops. This is a global variable initially set to 8. You can change this value with se_tabq().


Home Contents Previous Next