Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
fopen - opens a file for buffered reading or writing
Calling Sequence
fopen(name, mode)
fopen(name, mode, type)
Parameters
name
-
the name of the file to be opened
mode
one of READ, WRITE, or APPEND
type
optional, one of TEXT or BINARY
Description
Opens the file with the specified name for buffered reading or writing as specified by mode and returns a file descriptor (a small integer).
In most cases, it is not necessary to fopen a file in order to access it. The first operation performed on a file will open it if it is not already open. The fopen function is provided as a convenience to those porting code written in other languages (such as C) to Maple, and for those cases where it is desirable to override the default file type provided by the I/O functions.
If a type is specified, it indicates whether the file contains TEXT (a stream of characters) or BINARY (a stream of bytes). When opened as type TEXT, newline characters ("\n") are translated to the platform-appropriate representation when writing, and back to newline characters when reading.
If no type is specified, type TEXT is assumed.
On platforms (such as UNIX) where there is no distinction between text and binary files, a type specification is allowed, but superfluous.
The special file names 'default' and 'terminal' (symbols) refer to the current and top-level input or output streams.
If the file being opened is already open, fopen generates an error.
If the file is being opened for reading and does not exist, fopen generates an error.
If the file is being opened for writing and does not exist (and is not already open), it is created, if possible; otherwise, fopen generates an error. If the file does exist (and is not already open), it is truncated. Writing starts at the beginning of the file if WRITE was specified, and at the end of the existing file if APPEND was specified.
If the limit for the maximum number of simultaneously open files has been reached, fopen generates an error.
The number of open files allowed is system specific.
When writing many files, you must fclose() each of them to ensure that you do not run out of file handles.
For information on filenames, see file.
Thread Safety
The fopen command is thread safe as of Maple 15.
Parallel calls to file i/o commands on the same file descriptor will be serialized in an arbitrary order. If you need the commands to execute in a particular order you must use Maple's synchronization tools to enforce this. See Threads:-Mutex.
For more information on thread safety, see index/threadsafe.
Examples
Use of 'terminal' for output
This is a test
Note: fclose cannot be used with the terminal file descriptor
Error, (in fclose) operation not allowed on `terminal` stream
See Also
fclose, file, file_types, IO_errors, open
Download Help Document