previous next top contents index framed top this page unframed
The LF standard is the default for text files. Carriage return is ignored on input unless keepNul was set when the file was opened, meaning that most CRLF files are treated the same as LF files.
The MAINSAIL STRING constant eol consists of a single character, linefeed.
4.1.1. CRLF> Device Prefix
To open a CRLF-standard text file,
prefix its file name with CRLF>
($devModBrk on NT is '>').
Subsequently, eol characters written to the
file are translated to the
carriage-return-linefeed sequence, and when a
carriage return is read from the file, it is discarded;
since a
carriage return usually precedes a
linefeed (eol) character, this leaves
just the linefeed.
The use of CRLF> usually presents no problems for sequential files. For random-access files, however, problems arise if a program performs arithmetic on file positions based on the number of characters it has read from or written to a file, and any of the characters read or written is a carriage return or linefeed. The arithmetic may produce incorrect results in such cases because of the translation of a one-character sequence to a two-character sequence (on output) or the discarding of characters (on input). CRLF> should not be used for files where such calculations are performed.
For random output files opened using CRLF>, it is also possible to position so as to overwrite half of a two-character carriage-return-linefeed sequence, a potential source of additional confusion.
Because files opened with the CRLF> prefix have so many restrictions, CRLF> is not the default device prefix on NTPNT, even though most NT utilities create such files. However, most NT programs seem to process LF-standard files correctly as well.
It is possible to change MAINSAIL's default text file prefix to CRLF>, as described in Section 4.1.4. You may wish to do so if you know that your MAINSAIL program will not perform random I/O on CRLF files in such a way as to encounter the problems mentioned above.
The CRLF prefix is incompatible with the keepNul bit, which
specifies that carriage returns are to be retained when read from a
file; an error message is issued
when both keepNul and the CRLF
prefix are specified when a file is opened.
in your v1620.prm parameter file):
The default prefix can always be overridden by an explicit prefix as
part of the file name passed to open.
4.1.2. LF> Device Prefix
The LF>
device prefix does not modify the characters read or written to
it, except to discard NUL (and carriage
return) characters on input if keepNul is not set when the file
is opened, as described in Section 43.5 of the MAINSAIL Language Manual.
4.1.3. Changing the Default Text File Device Prefix
You can control the text file device prefix used by default by setting
one or more of the following STRING-valued global symbols (e.g., by
including a line like:
GLOBALSYMBOL defaultTextFileDevMod CRLF
4.1.4. Converting CRLF Files to LF Files and Vice Versa
You can use the MAINSAIL utility COPIER
to convert a CRLF file to a LF
file or vice versa by explicitly specifying the CRLF> and LF>
prefixes, as appropriate. For example,
to convert the LF-standard file
noCR to the CRLF-standard file hasCR:
*copier<eol>
Text File Copier
Input file (just <eol> to stop): LF>noCR<eol>
Output file: CRLF>hasCR<eol>
4.2. Environment Variables and File Names
NTPNT MAINSAIL recognizes
environment variables as part of file names
passed to open. An environment variable name within a file name is
delimited by percent signs (%).
Thus, if the variable xyz is defined as
c:\my\dir\, the file name %xyz%foo is expanded by MAINSAIL to
c:\my\dir\foo.
If an environment variable is not defined, it is replaced with the empty STRING. Thus, if the environment variable xyz is not defined, MAINSAIL expands %xyz%foo to just foo.
If a file name contains an odd
number of percent signs, the last percent
sign is not considered part of
an environment variable, and is
included in the file name that
MAINSAIL passes to the operating system.
Thus, the file name a%b is
passed unmodified to NT; if the environment
variable b is defined as xxx,
then a%b%c%d expands to axxxc%d.
4.3. File Names Containing Colons and SEARCHPATH * * ...
If you are using the NTFS file system, you should be aware that file
names containing colons (other than those part of a disk prefix)
have a special meaning; they refer to objects
with multiple data streams
(such file names are illegal on the FAT file
system). You may create such objects inadvertently if you issue
SEARCHPATH subcommands that affect
searchpaths specifying names that
contain colons.
The special treatment of colons normally causes no confusion. The compiler, by default, opens its output objmod and intmod files using names that contain colons, but if you are using the default searchpaths as created by a standard installation, those file names are mapped to names without colons. However, if you change those searchpaths, or if you specify a MAINEX SEARCHPATH subcommand of the form:
SEARCHPATH * * ...
then the default searchpath for compiler file names is masked, and the
compiler may wind up creating an object named mpn-obj
or mpn-int on the
directory where the output file would normally go.
4.4. Simultaneous Opens of the Same File
NTPNT MAINSAIL does not set
FILE_SHARE_READ when it opens a file for
output, so if one program opens an output file, other programs cannot
open the same file at the same time.
4.5. File Security Attributes
NTPNT MAINSAIL does not currently set or examine file security
attributes.
MAINSAIL System-Specific User's Guides, Chapter 4