File-Access Blocks

Connect the flow with a file.

Review file-access components and their input requirements. Keep file conventions and port definitions exact when integrating stored data.

File Access Block Models


OpenFileAppend

OpenFileApp

File: general_blocks/File_Access/OpenFileAppend.sim
Description
The model opens the specified file for write access, appending to the existing data in the file. If the open fails, then an error message is generated, and the output is NOT enabled.

Ports

Input Ports

  • trigger         Data Type: TRIGGER

Output Ports

  • ok     Data Type: TRIGGER

Parameters

  • File_Name       Data Type: ANY

WriteFile_String

WriteFileStr

File: general_blocks/File_Access/WriteFile_String.sim
Description
The model writes an arbitrary string, defined as parameter String to a file, named in parameter File_Name. It is triggered by a token arriving at it's in port. It passes the token out it's out port. The named file must be open for writing. The token is sent out if the string is successfully written to the file. The file is specified by the File_Name parameter. You can automatically identify the module from which the printing is coming, by the %Block_Label keyword as part of your string to be printed. This model will replace the keyword with the full path-name of the instance in the graph hierarchy. Ports

Input Ports

  • in              Data Type: TRIGGER

Output Ports

  • out             Data Type: TRIGGER

Parameters

  • File_Name           Data Type: ANY
  • String Data Type: ANY

WriteFile_Real

WriteFile

File: general_blocks/File_Access/WriteFile_Real.sim
Description
The model writes an real value to a specified file.
Ports

Input Ports

  • in           Data Type: REAL

Output Ports

  • out          Data Type: TRIGGER

Parameters

  • File_Name       Data Type: ANY

WriteFile_Int

WriteFileInt

File: general_blocks/File_Access/WriteFile_Integer.sim
Description
The model writes an integer value to a specified file.
Ports

Input Ports

  • in           Data Type: INTEGER

Output Ports

  • out          Data Type: TRIGGER

Parameters

  • File_Name       Data Type: ANY

WriteInfo_Numeric

WriteInfoNum

File: general_blocks/File_Access/WriteInfo_Numeric.sim

Description
The model writes an value to a file, which is specified from the Parameter File_Name. This value consist of concatenating the Parameter Leading_string , the numeric value from the in port, and  the Parameter Trailing_string . After writing to the file, the done port will be enabled.
Ports

Input Ports

  • in              Data Type: NUMERIC

Output Ports

  • done            Data Type: TRIGGER

Parameters

  • File_Name Data Type: ANY
  • Leading_string      Data Type: STRING
  • Trailing_string     Data Type: STRING

ReadFile_Real

ReadFileReal

File: general_blocks/File_Access/ReadFile_Real.sim
Description
The model reads an real value from a specified file. The file is specified by the parameter File_Name. When the model is triggered, the next value is read from the file. When end-of-file is encountered on a read, the eof output is enabled instead of the value output.
Ports

Input Ports

  • trigger          Data Type: TRIGGER

Output Ports

  • eof Data Type: TRIGGER
  • value           Data Type:  REAL

Parameters

  • File_Name       Data Type: ANY

ReadFile_Int

ReadFileInt

File: general_blocks/File_Access/ReadFile_Integer.sim

Description
The model reads an integer value from a specified file. The file
is specified by the parameter File_Name. When the model is

triggered, the next value is read from the file. When end-of-file
is encountered on a read, the eof output is enabled instead of
the value output.
Ports

Input Ports

  • trigger     Data Type: TRIGGER

Output Ports

  • eof Data Type: TRIGGER
  • value      Data Type: INTEGER

Parameters

  • File_Name       Data Type: ANY

OpenFileWrite

OpenFileWt

File: general_blocks/File_Access/OpenFileWrite.sim

Description
The model opens the specified file for write access. If the open fails, then an error message is generated, and the output is NOT enabled.
Ports

Input Ports

  • trigger     Data Type: TRIGGER

Output Ports

  • ok       Data Type: TRIGGER

Parameters

  • File_Name        Data Type: ANY

OpenFileRead

OpenFileRd

File: general_blocks/File_Access/OpenFileRead.sim

Description
The model opens the specified file for read access. If the open fails, then an error message is generated, and the output is NOT enabled.
Ports

Input Ports

  • trigger     Data Type: TRIGGER

Output Ports

  • ok Data Type: TRIGGER

Parameters

  • File_Name Data Type: ANY

CloseFile

File: general_blocks/File_Access/CloseFile.sim

Description
The model closes the file that is pointed to by the contents of the parameter File_Name.
If the file is not open an error message is reported.
Ports

Input Ports

  • trigger     Data Type: TRIGGER

Output Ports

  • done Data Type: TRIGGER

Parameters

  • File_Name        Data Type: ANY

ReadFile_Line

ReadFile Line

File: general_blocks/File_Access/ReadFile_Line.sim
Description
The model gets a line of text from the specified
file. The file is specified by the parameter File_Name.
When the model is triggered, it starts from the current
file pointer position and skips over n-1 lines of text,
until it gets to line n. n is specified by the
Line_Position parameter. After locating the line of text,
the line is then sent out the "value" port. When
end-of-file is encountered on a read, the eof output is
enabled instead.
Ports

Input Ports

  • trigger     Data Type: TRIGGER

Output Ports

  • eof Data Type: TRIGGER

  • value Data Type: CHAR

Parameters

  • File_Name        Data Type: CHAR

  • Number_of_Lines        Data Type: INTEGER


ReadFile_String

ReadFile String

File: general_blocks/File_Access/ReadFile_String.sim
Description
The model reads "white space delimited" strings from the
specified file. The file is specified by the parameter
File_Name. When the model is triggered, n-1 strings are
skipped over as they are read from the file. The n-th
string is sent out the "value" port. When end-of-file is
encountered on a read, the eof output is enabled instead
of the value output.
Ports

Input Ports

  • trigger     Data Type: TRIGGER

Output Ports

  • eof Data Type: TRIGGER

  • value Data Type: CHAR

Parameters

  • File_Name        Data Type: CHAR

  • Number_of_Strings        Data Type: INTEGER


WriteFile_Field

WriteFile Field

File: general_blocks/File_Access/WriteFile_Field.sim
Description
The model locates the specified field of a Composite Data specified file. The file is specified by the parameter file. It then passes the in data structure unmodified to out port.
Ports

Input Ports

  • in              Data Type: REAL

  • out Data Type: TRIGGER

Parameters

  • File_Name      Data Type: CHAR

  • Field_Name     Data Type: CHAR

  • *Delimiter      Data Type: CHAR

: Specify the character to follow the printed data. Allowable values are CR, TAB, SPACE and NONE.*


WriteFile_AppendField

WriteFile AppendField

File: general_blocks/File_Access/WriteFile_AppendField.sim
Description
The model locates the specified field of a Composite Data
specified file. The file is specified by the parameter
file. It then passes the in data structure unmodified to
out port.
Ports

Input Ports

  • in               Data Type: REAL

  • out Data Type: TRIGGER

Parameters

  • File_Name        Data Type: CHAR

  • Field_Name       Data Type: CHAR

  • Delimiter        Data Type: CHAR


This page is an editorial rewrite of source documentation. Historical status, availability, and platform notes are not independently verified for a current release. Technical examples are reference material, not a live simulator.