20#include "txt_out_file.h"
28TXT_OUT_FILE::~TXT_OUT_FILE(
void )
38 for(
int i=0; i<
nCol; i++ )sprintf(
cName[i],
"Var %d",i);
70 strcpy( file_name, TXT_file );
83 File =
fopen( TXT_file,
"r" );
86 fprintf( stderr,
"File open error to reading (%s)\n", TXT_file );
90 memset(
cName, 0, NCOL_MAX*32 );
100 for(
int j=0; j<
nRow; j++ )
103 for(
int i=0; i<
nCol; i++ )fscanf( File,
"%lf", &
dResult[i][j] );
113 if( file_flag == 0 )
return -1;
114 return Read( file_name );
121 File =
fopen( TXT_file,
"w" );
124 fprintf( stderr,
"File open error to writing (%s)\n", TXT_file );
128 for(
int i=0; i<
nCol+
iType; i++ )fprintf( File,
" %s",
cName[i] );
129 fprintf( File,
"\n" );
130 for(
int j=0; j<
nRow; j++ )
132 if(
iType)fprintf( File,
" %5d",
iObj[j] );
133 for(
int i=0; i<
nCol; i++ )fprintf( File,
" %#16.8g",
dResult[i][j] );
134 fprintf( File,
"\n" );
143 if( file_flag == 0 )
return -1;
144 return Write( file_name );
static FILE * fopen(const char *filename, const char *mode)
Cross-platform function to fopen function that supports UTF-8 encoded name.
static int nColumns(FILE *stream, char Par[][32])
Returns number of columns of text file (number of strings in the first line). Names of columns are st...
static int nLines(FILE *stream)
Returns number of lines of text file from current pointer to EOF.
virtual int Read(void)
reads the [.czy] file defined by SetName function
virtual int Write(void)
writes the [.czy] file defined by SetName function
char cName[NCOL_MAX][32]
array of variable names - up to NCOL_MAX names, 32 characters each
int nCol
number of columns/variables (up to NCOL_MAX)
int * iObj
pointer to array [nRow] first column value (int)
virtual char * GetName(void)
returns pathname of the output text file
TXT_OUT_FILE(int iTypeIn=0)
constructor
double ** dResult
pointer to array (size depends on iType) containing the results for all variables
virtual void InitTabs(int n, int m)
initialises arrays (n - number of columns, m - number of rows )
virtual void CleanTabs(void)
cleans (deletes) arrays
virtual void SetName(const char *FileName)
set pathname for of the output text file
virtual void Clean(void)
cleans local variables
int iType
type of txt file - possible types: 0 - nCol x nRow - only double type values 1 - (nCol-1) x nRow ...