FANDOM


Link titleSyntax

OPEN filename

(OPEN filename mode)

Explanation

OPEN prepares for input or output the DOS file or device specified by its input, and then outputs its assigned Logo stream number. Data may then be read using READ, READCHAR, READLINE, READLIST, READQUOTE and other Logo primitives by making STANDARD.INPUT the stream number. If the specified file or device does not exist, OPEN outputs FALSE.

Because a colon (:) is a delimiter, it must be preceded with \ to be read correctly by Logo. See also CLOSE and CREATE.

Legal MS-DOS device name include:

CON\: Keyboard and screen
AUX\: or COM1\: First asynchronous communications adapter
COM2\: Second asynchronous communciations adapter
LPT1\: or PRN\: First parallel printer
LPT2\: Second parallel printer
LPT3\: Third parallel printer
NUL\: Null device

OPEN may optional be supplied with a third input which describes the open mode. This is a string consisting of one or more characters. The flowing modes are supported:

"R The file is opened for reading only. If the file does not exist, an error is generated.
"W The file is opened for writing only. If the file does not exist, it is created. Any data in the file is overwritten.
"RW The file is opened for both reading and writing. If the file does not exist, it is created.
"A The file is opened for writing only. If the file does not exist, it is created. The data written is appended to the end of the file

Optionally, this string may be followed by the letter "B which marks the file as binary. Normally, reading stops at the end of a line feed character, and line feed characters written are translated into CR/LF character pairs. If the file is opened in binary mode all data is transferred untranslated.

The commands .READ, .WRITE and .SEEK are available for low level I/O.

Examples

? OPEN "PRN\:

Result: 1

?

The following procedure prevents procedure names from displaying on the screen when Logo loads the file PICTURES. Instead, it redirects the Logo output stream to a null device.

TO LOADIT

MAKE "STANDARD.OUTPUT OPEN "NUL\:
MAKE "LOADED? LOAD "PICS.LGO
MAKE "STANDARD.OUTPUT 0

END

? LOAD "PICS.LGO

Loading File: PICS.LGO

CIRCLE is defined.

SQUARE is defined.

TRIANGLE is defined.

? LOADIT

PICS.LGO

?

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.