//return types for the scripting
const int LOGFILE_OK = 0;
const int LOGFILE_BAD = 1;
//the logfile class - creates a file and logs all the information on
//how the program behaves to it
class LOGFILE
{
public:
~LOGFILE();
ofstream outfile;
int CreateLogFile(const char* FileName);
int LogtoFile(char Outputstring[256]);
void CloseLogFile();
};
The functions...
//--------------------------------------------------//
// Name: ~LOGFILE()
// Desc: destructor that closes the logfile
//--------------------------------------------------//
LOGFILE::~LOGFILE()
{
//close the file
outfile.close();
}
//--------------------------------------------------//
// Name: CreateLogFile()
// Desc: function that creates a file called log.dat
//--------------------------------------------------//
int LOGFILE::CreateLogFile(const char* FileName)
{
//create the file and test if it was made ok
outfile.open(FileName);
if(!outfile)
{
return LOGFILE_BAD;
}
//return ok
return LOGFILE_OK;
};
//--------------------------------------------------//
// Name: LogtoFile()
// Desc: function that puts a string to the file
//--------------------------------------------------//
int LOGFILE::LogtoFile(char OutputString[256])
{
//output it to the file and flush it so it doesn't
//get lost if the program messes up
outfile<<OutputString;
outfile.flush();
//return ok
return LOGFILE_OK;
}
//--------------------------------------------------//
// Name: LogtoFile()
// Desc: function that puts a string to the file
//--------------------------------------------------//
void LOGFILE::CloseLogFile()
{
//close the file
outfile.close();
}
Now the problem is that I want to be able to specify the file by doing something like:
LOGFILE d3dlogfile.
d3dlogfile.CreateLogFile("system//data.log");
Now how exactly would I go about modifying it so that it works properly?
Moe's site
Edited by - Moe on January 8, 2002 8:46:03 PM