Working through my .CLP file loads this morning I kept receiving generic load error messages "Could not load file XXXX.CLP." After tracing through the issue I observed the following:
1. I put a break point at the start of the Load (CLIPSNET_Environment.cpp - Environment::Load)
if (ebFileName->Length)
{
pin_ptr<byte> pbFileName = &ebFileName[0]; if (m_Env->Load((char *) pbFileName) == 0)
{
CaptureEnd(commandCapture,false);
throw gcnew System::IO::FileNotFoundException(
"Could not load file '" + fileName + "'.",
fileName);
}
}
2. Which calls down into Clipscpplib.cpp (CLIPSCPPEnv::Load)
int CLIPSCPPEnv::Load(
char *theFile)
{</byte>
ifndef CLIPS_DLL_WRAPPER
return ::Load(theEnv,theFile);
else
return __Load(theEnv,theFile);
endif
}
Which returns the value of the Load call in cstrcpsr.c (Load). Load returns LE_NO_ERROR because noErrorsDetected is set to 1.
/=================/
/ Close the file. /
/=================/
GenClose(theEnv,theFile);
/=================================================/
/ If no errors occurred during the load, return /
/ LE_NO_ERROR, otherwise return LE_PARSING_ERROR. /
/=================================================/
The check back in Environment::Load throws an error if the return is 0 (LE_NO_ERROR). I modified the condiftional to throw an error when the return is non-zero (LE_OPEN_FILE_ERROR, LE_PARSING_ERROR).
if (ebFileName->Length)
{
pin_ptr<byte> pbFileName = &ebFileName[0];
if (m_Env->Load((char *) pbFileName) != 0)
{
CaptureEnd(commandCapture,false);
throw gcnew System::IO::FileNotFoundException(
"Could not load file '" + fileName + "'.",
fileName);
}
}</byte>
I get the feeling that I am not seeing something here that I should. Is this a correct solution for my problem or am I missing something?
Thanks for any help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Working through my .CLP file loads this morning I kept receiving generic load error messages "Could not load file XXXX.CLP." After tracing through the issue I observed the following:
1. I put a break point at the start of the Load (CLIPSNET_Environment.cpp - Environment::Load)
if (ebFileName->Length)
{
pin_ptr<byte> pbFileName = &ebFileName[0];
if (m_Env->Load((char *) pbFileName) == 0)
{
CaptureEnd(commandCapture,false);
throw gcnew System::IO::FileNotFoundException(
"Could not load file '" + fileName + "'.",
fileName);
}
}
2. Which calls down into Clipscpplib.cpp (CLIPSCPPEnv::Load)
int CLIPSCPPEnv::Load(
char *theFile)
{</byte>
ifndef CLIPS_DLL_WRAPPER
return ::Load(theEnv,theFile);
else
return __Load(theEnv,theFile);
endif
}
SetLoadInProgress(theEnv,true);
noErrorsDetected = LoadConstructsFromLogicalName(theEnv,(char *) theFile);
SetLoadInProgress(theEnv,false);
SetParsingFileName(theEnv,oldParsingFileName);
DeleteString(theEnv,oldParsingFileName);
SetWarningFileName(theEnv,NULL);
SetErrorFileName(theEnv,NULL);
SetFastLoad(theEnv,NULL);
/=================/
/ Close the file. /
/=================/
GenClose(theEnv,theFile);
/=================================================/
/ If no errors occurred during the load, return /
/ LE_NO_ERROR, otherwise return LE_PARSING_ERROR. /
/=================================================/
if (noErrorsDetected)
{ return LE_NO_ERROR; }
return LE_PARSING_ERROR;
}
typedef enum
{
LE_NO_ERROR = 0,
LE_OPEN_FILE_ERROR,
LE_PARSING_ERROR,
} LoadError;
The check back in Environment::Load throws an error if the return is 0 (LE_NO_ERROR). I modified the condiftional to throw an error when the return is non-zero (LE_OPEN_FILE_ERROR, LE_PARSING_ERROR).
if (ebFileName->Length)
{
pin_ptr<byte> pbFileName = &ebFileName[0];
if (m_Env->Load((char *) pbFileName) != 0)
{
CaptureEnd(commandCapture,false);
throw gcnew System::IO::FileNotFoundException(
"Could not load file '" + fileName + "'.",
fileName);
}
}</byte>
I get the feeling that I am not seeing something here that I should. Is this a correct solution for my problem or am I missing something?
Thanks for any help!
Apologies for the long delay. Your solution is correct.