D
DLueck
I am getting a debug assertion error that reads:
Debug Assertion Failed!
program E:\program files\internet explorer\iexplore,exe
File: dbgheap.c
Line: 1252
Expression: _CrtIsValidHeapPointer(pUserData)
here is my code.
// DEFINE VAIRABLES
CString DataStream;
int DataArray[11];
int iCounter;
string sBuffer;
int pos;
bool bDone;
int m_count;
int nStrPos;
int nLength;
int d = 0;
CString MonitorCaption;
bool GetMoreData = true;
// initial log events variable
if (LogInformation == "TRUE")
{
LogEvents = 0;
}
else
{
LogEvents = -1;
}
// set up interface pointer
CPDSInterface* PDSInterface;
if (PDSInterface != NULL)
{
PDSInterface = NULL;
}
// initialize variables for process
DWORD Error = 0;
if (PDSInterface != NULL)
{
PDSInterface = NULL;
}
PDSInterface = new CPDSInterface();
// establishe iniital connect
d = PDSInterface->Initialize("127.0.0.1");
if (d != SUCCESS)
{
if (LogEvents == 0)
{
CString strMessage("Failured to initialize Monitor");
ErrorLog(strMessage);
}
return;
}
// need to open a connection to the gateway first..
d = PDSInterface->Connect("196.76.0.1");
if (d != SUCCESS)
{
if (LogEvents == 0)
{
CString strMessage("Failured to Connect to Monitor");
ErrorLog(strMessage);
}
return;
}
// clear the buffers
d = PDSInterface->ClearData("196.76.0.1");
if (d != SUCCESS)
{
if (LogEvents == 0)
{
CString strMessage("Failured to clear the buffer of Monitor");
ErrorLog(strMessage);
}
return;
}
// udpdate caption of button
MonitorCaption = m_Caption;
COleControl::SetText(MonitorCaption);
COleControl::RedrawWindow(0,0,RDW_UPDATENOW);
// main loop
try
{
while (GetMoreData)
{
Sleep(1000);
DoEvents();
if (LogEvents == 0)
{
CString strMessage("before datastream");
ErrorLog(strMessage);
}
if (PDSInterface == NULL)
{
CString strMessage("PDSInterface is NULL.");
CString strTitle("TITLE");
MessageBox(strMessage, strTitle, MB_OK);
}
// get data from monitor
d = PDSInterface->GetData("196.76.0.1", DataStream);
if (LogEvents == 0)
{
CString strMessage(DataStream);
ErrorLog(strMessage);
}
if (DataStream == "")
{
CString strMessage("DataStream is NULL");
ErrorLog(strMessage);
}
Sleep(1000);
DoEvents();
if ((d == SUCCESS) && (DataStream != ""))
{
// reset variables
m_count = 0;
pos = 0;
iCounter = 0;
bDone = false;
// convert cstring to string, to be able to work with the string
properties
CT2CA pszConvertedAnsiString (DataStream);
string sWorkString (pszConvertedAnsiString);
// parse data steam into data array
pos = sWorkString.find(' ');
if (LogEvents == 0)
{
CString strMessage("Before Parsing");
ErrorLog(strMessage);
}
if (pos >= 0)
{
nLength = sWorkString.size();
// we have work to do,and we have to do it one character at a time
sBuffer = "";
nStrPos = 0;
do
{
char cCharToAdd = sWorkString.at(nStrPos);
if (cCharToAdd != ' ')
{
//add the character
sBuffer += cCharToAdd;
nStrPos++;
}
else
{
if (sBuffer == "-32767")
{
DataArray[iCounter] = 0;
}
else
{
DataArray[iCounter] = atoi(sBuffer.c_str());
}
iCounter++;
nStrPos++;
sBuffer = "";
}
if (nStrPos >= nLength)
{
bDone = true;
}
} while (!bDone);
}
if (LogEvents == 0)
{
CString strMessage("After Parsing");
ErrorLog(strMessage);
}
// move data to variables
int Systolic = DataArray[1];
int Diastolic = DataArray[2];
int ETCO2 = DataArray[5];
int PulseRate = DataArray[6];
int RespirationRate = DataArray[8];
int SPO2 = DataArray[10];
// Update Web Page
UpdateWebPage(PulseRate, Systolic, Diastolic, SPO2, RespirationRate);
DoEvents();
if (LogEvents == 0)
{
CString strMessage("after web update");
ErrorLog(strMessage);
}
Sleep(1000);
DoEvents();
// write to log
WriteToLog(PulseRate,Systolic,Diastolic,SPO2,RespirationRate);
DoEvents();
}
if (LogEvents == 0)
{
CString strMessage("before returning to top");
ErrorLog(strMessage);
}
}
}
// catch all errors
catch(...)
{
GetMoreData = false;
}
return;
please help,
Debug Assertion Failed!
program E:\program files\internet explorer\iexplore,exe
File: dbgheap.c
Line: 1252
Expression: _CrtIsValidHeapPointer(pUserData)
here is my code.
// DEFINE VAIRABLES
CString DataStream;
int DataArray[11];
int iCounter;
string sBuffer;
int pos;
bool bDone;
int m_count;
int nStrPos;
int nLength;
int d = 0;
CString MonitorCaption;
bool GetMoreData = true;
// initial log events variable
if (LogInformation == "TRUE")
{
LogEvents = 0;
}
else
{
LogEvents = -1;
}
// set up interface pointer
CPDSInterface* PDSInterface;
if (PDSInterface != NULL)
{
PDSInterface = NULL;
}
// initialize variables for process
DWORD Error = 0;
if (PDSInterface != NULL)
{
PDSInterface = NULL;
}
PDSInterface = new CPDSInterface();
// establishe iniital connect
d = PDSInterface->Initialize("127.0.0.1");
if (d != SUCCESS)
{
if (LogEvents == 0)
{
CString strMessage("Failured to initialize Monitor");
ErrorLog(strMessage);
}
return;
}
// need to open a connection to the gateway first..
d = PDSInterface->Connect("196.76.0.1");
if (d != SUCCESS)
{
if (LogEvents == 0)
{
CString strMessage("Failured to Connect to Monitor");
ErrorLog(strMessage);
}
return;
}
// clear the buffers
d = PDSInterface->ClearData("196.76.0.1");
if (d != SUCCESS)
{
if (LogEvents == 0)
{
CString strMessage("Failured to clear the buffer of Monitor");
ErrorLog(strMessage);
}
return;
}
// udpdate caption of button
MonitorCaption = m_Caption;
COleControl::SetText(MonitorCaption);
COleControl::RedrawWindow(0,0,RDW_UPDATENOW);
// main loop
try
{
while (GetMoreData)
{
Sleep(1000);
DoEvents();
if (LogEvents == 0)
{
CString strMessage("before datastream");
ErrorLog(strMessage);
}
if (PDSInterface == NULL)
{
CString strMessage("PDSInterface is NULL.");
CString strTitle("TITLE");
MessageBox(strMessage, strTitle, MB_OK);
}
// get data from monitor
d = PDSInterface->GetData("196.76.0.1", DataStream);
if (LogEvents == 0)
{
CString strMessage(DataStream);
ErrorLog(strMessage);
}
if (DataStream == "")
{
CString strMessage("DataStream is NULL");
ErrorLog(strMessage);
}
Sleep(1000);
DoEvents();
if ((d == SUCCESS) && (DataStream != ""))
{
// reset variables
m_count = 0;
pos = 0;
iCounter = 0;
bDone = false;
// convert cstring to string, to be able to work with the string
properties
CT2CA pszConvertedAnsiString (DataStream);
string sWorkString (pszConvertedAnsiString);
// parse data steam into data array
pos = sWorkString.find(' ');
if (LogEvents == 0)
{
CString strMessage("Before Parsing");
ErrorLog(strMessage);
}
if (pos >= 0)
{
nLength = sWorkString.size();
// we have work to do,and we have to do it one character at a time
sBuffer = "";
nStrPos = 0;
do
{
char cCharToAdd = sWorkString.at(nStrPos);
if (cCharToAdd != ' ')
{
//add the character
sBuffer += cCharToAdd;
nStrPos++;
}
else
{
if (sBuffer == "-32767")
{
DataArray[iCounter] = 0;
}
else
{
DataArray[iCounter] = atoi(sBuffer.c_str());
}
iCounter++;
nStrPos++;
sBuffer = "";
}
if (nStrPos >= nLength)
{
bDone = true;
}
} while (!bDone);
}
if (LogEvents == 0)
{
CString strMessage("After Parsing");
ErrorLog(strMessage);
}
// move data to variables
int Systolic = DataArray[1];
int Diastolic = DataArray[2];
int ETCO2 = DataArray[5];
int PulseRate = DataArray[6];
int RespirationRate = DataArray[8];
int SPO2 = DataArray[10];
// Update Web Page
UpdateWebPage(PulseRate, Systolic, Diastolic, SPO2, RespirationRate);
DoEvents();
if (LogEvents == 0)
{
CString strMessage("after web update");
ErrorLog(strMessage);
}
Sleep(1000);
DoEvents();
// write to log
WriteToLog(PulseRate,Systolic,Diastolic,SPO2,RespirationRate);
DoEvents();
}
if (LogEvents == 0)
{
CString strMessage("before returning to top");
ErrorLog(strMessage);
}
}
}
// catch all errors
catch(...)
{
GetMoreData = false;
}
return;
please help,