13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The file identifier is the name of a file variable of type TEXT orINTERACTIVE, corresponding to an open character device or disk file. If itis omitted, OUTPUT (the monitor screen) is assumed.Each value expression contains material to be written as text; it may beany Pascal expression of type INTEGER, REAL, long integer, CHAR,STRING, or PACKED ARRAY OF CHAR.Each width expression is an expression of type INTEGER. It specifies theminimum number of characters in the text equivalent of the associatedvalue expression. If the actual text takes fewer characters, it isright-justified with spaces (that is, spaces are added to the front end until itfills the minimum width). If no width expression is specified, only thecharacters necessary for the value expression are written.Decimal places expressions are used only with value expressions of typeREAL. Each one specifies the number of decimal places to be written in thetext equivalent.WRITE must always be followed by at least one value expression; otherthan that, all parts of the syntax following WRITE or WRITELN areoptional.Here are some examples of using WRITE and WRITELN:WRITE CDMP, 'Hello');WRITE CSTORFILE, N+2);WRITE CA, ' ', N>;WRITELN CZ/3.14:9:5);WR ITELN;{string constant to printer}{integer value to disk file}{string variable, space, integer to screen}{real value to screen; 9 chars, 5 decimals}{new line on screen}Here are the principal rules that govern the use of WRITE and WRITELN.Some special rules about their handling of control characters are given inChapter 16 under "Special Handling of Control Characters."o WRITELN adds a RETURN character (ASCII 13) at the end of its output.If it is writing to a character device it follows this with a LINE FEED(ASCII 10).o When an integer, real, or long integer value is written, it is preceded by aminus sign ( - ) if negative, a space character if positive. This characteris included in its width count.o If a width expression is used with a value of type STRING or PACKEDARRAY OF CHAR, the value is truncated if it is too long andright-justified with leading spaces if it is too short. The resulting format isnot limited to the usual string maximum of 255 characters.Character File 1/0 OperationsIII-175

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!