Tips for finding scope problems
I have the following code here. My problem is that when the switch...case block hits nIDEvent == 1, SlavePos structure (which is an array of 6 floating point numbers) is modified by (0, +/- delta, 0, 0, 0, 0). But when the debugger hits the line "break;", SlavePos's values return to the original values before exiting the function. Does anyone know what type of scope problem that I'm running into in this case? Thanks in advance.
Code:
void InsertSimulGLrender::OnTimer( UINT_PTR nIDEvent )
{
BrachySimApp *theApp = (BrachySimApp*) AfxGetApp();
float delta = 0.05;
switch(nIDEvent)
{
case 1:
// This is used to attempt to move the needle
if (lpressed)
theNeedle->SlavePos[1] -= delta;
if (rpressed)
theNeedle->SlavePos[1] += delta;
break;
case 2:
// some other handling code that is not relevant to the problem
break;
}
CView::OnTimer(nIDEvent);
}