ficlose

ficlose — Closes a previously opened file.

Description

ficlose can be used to close a file which was opened with fiopen.

Syntax

ficlose ihandle
ficlose Sfilename

Initialization

ihandle -- a number which identifies this file (generated by a previous fiopen).

Sfilename -- A string in double quotes or string variable with the filename. The full path must be given if the file directory is not in the system PATH and is not present in the current directory.

Performance

ficlose closes a file which was previously opened with fiopen. ficlose is only needed if you need to read a file written to during the same csound performance, since only when csound ends a performance does it close and save data in all open files. The opcode ficlose is useful for instance if you want to save presets within files which you want to be accesible without having to terminate csound.

[Note] Note

If you don't need this functionality it is safer not to call ficlose, and just let csound close the files when it exits.

If a files closed with ficlose is being accessed by another opcode (like fout or foutk), it will be closed later when it is no longer being used.

[Warning] Warning

This opcode should be used with care, as the file handle will become invalid, and will cause an init error when an opcode tries to access the closed file.

Examples

Here is an example of the ficlose opcode. It uses the file ficlose.csd.

Example 248. Example of the ficlose opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
 
; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o ficlose.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
 

sr = 44100 
ksmps = 32 
nchnls = 2 
0dbfs  = 1 

gihand fiopen "test1.txt", 0 

instr 1

ires  random  0, 100
      fouti gihand, 0, 1, ires 
      ficlose gihand 

endin 
</CsInstruments>
<CsScore>
 

i 1 0 1 

e
</CsScore>
</CsoundSynthesizer>


See Also

fiopen, fout, fouti, foutir, foutk

Credits

Author: Gabriel Maldonado
Italy
1999

New in Csound version 5.02