The Solar-Stellar Spectrograph

[ Home | About | Tech Info & Data | Publications | References ]      [ Site by Jeffrey Hall | Research funded by NSF ]

ARTICLE

Filelink

The Filelink class is a generic file I/O class. It inherits Root.

This class associates its child object with a disk file. It does not perform any excessively complex operations; its purpose is to encapsulate frequently used (and frequently miscoded) IDL file association commands into a simple command interface.

The class keeps track of which file is associated with the object via the data member fileName, when the file was last modified, and whether is has been modified since the object was created, encapsulating the opening and closing commands for consistent allocation and freeing of LUNs.

Version History

2008 July 07 - Documentation written.

 

Data Members

string fileName

long lun

double lastMod

bool isMod

 

Method List

cleanup

close_datafile( )

define

dump_stat

get_datafile( )

init( )

is_modified( )

is_valid( )

modified

open_datafile( )

set_datafile

stat_datafile( )

 

Method Descriptions

 

PRO cleanup

Calls Root::cleanup

Destructor. Clears its history list by calling Root::clear_history via Root::cleanup. Never call this procedure directly; it is invoked by IDL's Obj_Destroy function.

 

FUNCTION close_datafile

Calls Root::add_history

Return bool b

Closes the data file fileName and free the LUN associated with the stream. An error is written to the history list if there is an IO error.

 

PRO define

Structure definition. Specifies the contents of the IDL structure instantiated by the Filelink class. Used by Obj_New; do not invoke directly.

 

PRO dump_stat

Calls Root::dump_stat

This is a standard OIL class method. It dumps the current state of the object's data members, followed by those of the Root object, to the command output window. The dump will look best if the output font is fixed rather than proportional width.

 

FUNCTION get_datafile

Return string fileName

Returns the object's fileName data member, containing the file name to which the object is linked.

 

FUNCTION init

keyword string fileName

keyword struct _EXTRA

Return bool TRUE

Constructor. The keyword fileName is used to supply an initial value for the filename. If it is not set, the filename will be initialized to 'NULL' (this will also add an !OIL_WRN to the history list noting this). Never call this function directly; it is invoked by IDL's Obj_New function.

 

FUNCTION is_modified

Return bool isMod

Returns the object's isMod data member.

 

FUNCTION is_valid

Calls Root::add_history, Root::is_valid

Return long[2] valid

Each OIL class has an is_valid function that performs class-specific tests on its data members. If all members are found to be valid, however validity is defined for that class, this funtion returns 1. Otherwise, a negative number is returned that contains a bitwise combination of all errors detected. In the case of Filelink, the error codes are: -1 (filename is NULL) or -2 (isMod is not a Boolean value). The Filelink override of this function returns a two-element array of longs, the first element containing the validity state of the Root, and the second that of the Filelink. An event is written to the log if the Filelink is invalid.

 

PRO modified

Calls Root::add_history

Sets the value of the object's lastMod and isMod data members to the time of modification and !TRUE, respectively.

 

FUNCTION open_datafile

keyword bool w

keyword bool a

Calls Root::add_history

Return bool b

Opens the file fileName for writing (if the w keyword is set) or in append mode (if the a keyword is set). An error is written to the history list if there is an IO error.

 

PRO set_datafile

argument string filename

Calls modified, Root::add_history

Sets the value of the object's f data member, the file name associated with the object.

 

FUNCTION stat_datafile

Calls Root::add_history

Return bool, struct fs

Runs the IDL routine FStat on a file, returning !FALSE if no file is open.

 

Sample Usage

obj = Obj_New( 'Filelink', fileName = 'C:\mydir\somefile' )

Obj_Destroy( obj )

 


[Back to contents]

Supported by grants from the National Science Foundation.
[ Back to my home page | Email me: jch [at] lowell [dot] edu ]
The SSS is publicly funded. Unless explicitly noted otherwise, everything on this site is in the public domain.
If you use or quote our results or images, we appreciate an acknowledgment.
This site is best viewed with Mozilla Firefox.