Next: , Previous: END FILE, Up: Data Input and Output



6.6 FILE HANDLE

     FILE HANDLE handle_name
             /NAME='filename'
             /MODE={CHARACTER,IMAGE}
             /LRECL=rec_len
             /TABWIDTH=tab_width

Use FILE HANDLE to associate a file handle name with a file and its attributes, so that later commands can refer to the file by its handle name. Because names of text files can be specified directly on commands that access files, FILE HANDLE is only needed when a file is not an ordinary file containing lines of text. However, FILE HANDLE may be used even for text files, and it may be easier to specify a file's name once and later refer to it by an abstract handle.

Specify the file handle name as an identifier. Any given identifier may only appear once in a PSPP run. File handles may not be reassigned to a different file. The file handle name must immediately follow the FILE HANDLE command name.

The NAME subcommand specifies the name of the file associated with the handle. It is the only required subcommand.

MODE specifies a file mode. In CHARACTER mode, the default, the data file is opened in ANSI C text mode, so that local end of line conventions are followed, and each text line is read as one record. In CHARACTER mode, most input programs will expand tabs to spaces (DATA LIST FREE with explicitly specified delimiters is an exception). By default, each tab is 4 characters wide, but an alternate width may be specified on TABWIDTH. A tab width of 0 suppresses tab expansion entirely.

By contrast, in BINARY mode, the data file is opened in ANSI C binary mode and records are a fixed length. In BINARY mode, LRECL specifies the record length in bytes, with a default of 1024. Tab characters are never expanded to spaces in binary mode.