MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Instrukcja Obsługi Strona 47

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 282
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 46
Compiler Directives
2-27
Output File Control
The structure of the output file control construct is:
%openfile string optional-equal-string optional-mode
%closefile id
%selectfile id
The %openfile directive opens a file or buffer for writing; the required string
variable becomes a variable of type
file. For example:
%openfile x /% Opens and selects x for writing. %/
%openfile out = "out.h" /% Opens "out.h" for writing. %/
The %selectfile directive selects the file specified by the variable as the
current output stream. All output goes to that file until another file is selected
using
%selectfile. For example:
%selectfile x /% Select file x for output. %/
The %closefile directive closes the specified file or buffer, and if this file is the
currently selected stream,
%closefile invokes %selectfile to reselect the last
previously selected output stream.
There are two possible cases that
%closefile must handle:
If the stream is a file, the associated variable is removed as if by
%undef.
If the stream is a buffer, the associated variable receives all the text that has
been output to the stream. For example:
%assign x = "" /% Creates an empty string. %/
%openfile x
"hello, world"
%closefile x /% x = "hello, world\n"%/
If desired, you can append to an output file or string by using the optional
mode,
a, as in:
%openfile "foo.c", "a" %% Opens foo.c for appending.
Przeglądanie stron 46
1 2 ... 42 43 44 45 46 47 48 49 50 51 52 ... 281 282

Komentarze do niniejszej Instrukcji

Brak uwag