GiD - The personal pre and post processor

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


GiD_File fopen|fclose|fprintf|fflush|list
To allow print data from a Tcl procedure with standard fprintf command, specially to write the calculation file from Tcl or a mix of .bas template and Tcl procedures

  • GiD_File fopen <filename> ?<access>?

Open a file named <filename> for writting access. By default access is "w", but is possible to use "a" to append to a previous file (and "wb" or "ab" to open the file in binary mode). It returns a long integer <file_id> representing the channel

  • GiD_File fclose <file_id>

Close a channel

  • GiD_File fprintf -nonewline <file_id> <format> ?<arg>? ... ?<arg>?

Print data from a Tcl procedure in a file opened with GiD_File fopen and returns the number of printed characters.
(a .bas template implictly open/close a file with this command, and the file_id could be send to a tcl procedure as a parameter with the *FileId template keyword)
<file_id> must be a valid file descriptor, that could be obtained in a .bas template with the *FileId command (or with GiD_File fopen)
<format> must be a valid C/C++ format, according with the arguments
return

  • GiD_File fflush <file_id>

Force unwritten buffered data to be written to the file

  • GiD_File list

It returns a list of currently open file_ids


Example:
.bas file:

Number of points and lines: *tcl(MyMethod *FileId)


.tcl file:

proc MyMethod { channel } {
    GiD_File fprintf -nonewline $channel {%d %d} [GiD_Info Geometry NumPoints] [GiD_Info Geometry NumLines]
}


  • No labels