The following snippet shows how DSS should generally be used in a program.


// Near the start of your program, set a log file to record transactions
// so in case a user runs into problems, they can look there for issues
// This will create a log file in the users temp directory
int status = HecDataManager.setLogFile("MyProgramName");
if (status != 0) . . . 
// If you will access only one DSS file, then set it as default
// It will not be opened until accessed, so any file error
// will show up then. You can use "setDSSFileName()" for individual objects
// if you need to access more than one DSS file. 
HecDataManager.setDefaultDSSFileName("MyDSS_file.dss"); 

// Later in your program, read and write to DSS
TimeSeriesContainer tscRead = new TimeSeriesContainer();
tscRead.fullName = "/Basin/Location/Flow/01Jan2010/1Hour/Java Example/";
HecTimeSeries dssTimeSeriesRead = new HecTimeSeries();
status = dssTimeSeriesRead.setDSSFileName("C:/temp/Sample7.dss"); 
if (status < 0) {
// This means the open failed; could be lots of reasons, such
// as a permission issue, a bad DSS file name, etc. You cannot continue.
DSSErrorMessage error = dataManager.getLastError();
// return proecessError(error); It is recommended that you write a function to handle errors
error.printMessage();
return;
} 
status = dssTimeSeriesRead.read(tscRead, true);
// When you are finished with an object, always tell it that you are done
dssTimeSeriesRead.done(); 
if (status < 0) . . . // Do some error processing here 

// At the end of your program, do some housekeeping
// This is not critical, but recommended to release space 
HecDataManager.closeAllFiles();
HecDataManager.closeLogFile(); 
JAVA