Message 1 of 3
Opening Files
Not applicable
10-28-2003
11:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm writing an arx program that asks a user for a file input, and then
opens the file they select from a dialog box. For some reason though,
my program seems to get messed up with the filename after the user
selects the file. That is, sometimes when I select the file, it reports
it's trying to open a filename which is blank, or garbled. But if I try
to open the file several times in a row, it will work again.
Any Clues?
Much Appreciated
-Jacob
bool GetFile( /* inout */ ::ifstream& inFile,
/* in */ char *msg)
{
char *fileName;
// AutoCAD specific file open dialog control
const char* title = msg; // Dialog box title
const char* defaultd = "/work/"; // Default directory
struct resbuf *fname; // Result buffer
fname = acutNewRb(RTSTR);
if(acedGetFileD(title, defaultd, "LIN", 16, fname) == RTNORM)
{
fileName = fname->resval.rstring;
}
// Release the result buffer
acutRelRb(fname);
// Now that the AutoCAD part is done, lets open the file.
acutPrintf("\n Attempting to open the file %s \n",fileName);
inFile.open(fileName);
if ( !inFile )
{
acutPrintf("\n *** Can't open input file *** \n");
delete fileName;
return false;
}
// Report success and delete our filename pointer.
acutPrintf("\n File Opened Successfully \n");
delete fileName;
return true;
}
opens the file they select from a dialog box. For some reason though,
my program seems to get messed up with the filename after the user
selects the file. That is, sometimes when I select the file, it reports
it's trying to open a filename which is blank, or garbled. But if I try
to open the file several times in a row, it will work again.
Any Clues?
Much Appreciated
-Jacob
bool GetFile( /* inout */ ::ifstream& inFile,
/* in */ char *msg)
{
char *fileName;
// AutoCAD specific file open dialog control
const char* title = msg; // Dialog box title
const char* defaultd = "/work/"; // Default directory
struct resbuf *fname; // Result buffer
fname = acutNewRb(RTSTR);
if(acedGetFileD(title, defaultd, "LIN", 16, fname) == RTNORM)
{
fileName = fname->resval.rstring;
}
// Release the result buffer
acutRelRb(fname);
// Now that the AutoCAD part is done, lets open the file.
acutPrintf("\n Attempting to open the file %s \n",fileName);
inFile.open(fileName);
if ( !inFile )
{
acutPrintf("\n *** Can't open input file *** \n");
delete fileName;
return false;
}
// Report success and delete our filename pointer.
acutPrintf("\n File Opened Successfully \n");
delete fileName;
return true;
}