Seconded. The results you get are perfectly possible, baring any additional constraints in code you haven't posted. Consider the following (code reposted with line numbers):
/* 01 */ HRESULT SubMenuIClass::Update(MouseBuff MsDevice)/* 02 */ {/* 03 */ if (this->ID == 700)/* 04 */ {/* 05 */ Log("!!!!!New update for GShapes submenu \n ");/* 06 */ }/* 07 */ /* 08 */ if (this->ID == 700)/* 09 */ {/* 10 */ if ( ( ( (MsDevice.X > SubmenuIButt[0].LeftEdge) && (MsDevice.Y > SubmenuIButt[0].UpperEdge) ) &&/* 11 */ ( (MsDevice.X < SubmenuIButt[0].RightEdge) && (MsDevice.Y < SubmenuIButt[0].LowerEdge) ) ) && /* 12 */ (MsDevice.LBDown) )/* 13 */ {/* 14 */ Log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Menu button should go down now!!!! \n ");/* 15 */ }/* 16 */ }/* 17 */ /* 18 */ //------------------------- /* 19 */ /* 20 */ for (int ButtonNumber =0; ButtonNumber<NrOfButtons; ButtonNumber++)/* 21 */ {/* 22 */ if (!SubmenuIButt[ButtonNumber].NoDown)/* 23 */ {/* 24 */ if (this->ID == 700)/* 25 */ Log("Ready to evaluate Interface button state \n ");/* 26 */ /* 27 */ if ( ( ( (MsDevice.X > SubmenuIButt[ButtonNumber].LeftEdge) && (MsDevice.Y > SubmenuIButt[ButtonNumber].UpperEdge) ) &&/* 28 */ ( (MsDevice.X < SubmenuIButt[ButtonNumber].RightEdge) && (MsDevice.Y < SubmenuIButt[ButtonNumber].LowerEdge) ) ) &&/* 29 */ (MsDevice.LBDown) )/* 30 */ { /* 31 */ if (this->ID == 700)/* 32 */ Log("This message never gets printed");/* 33 */ /* 34 */ SubmenuIButt[ButtonNumber].PlaySound(); // Play the buttons sound when the button is being pressed/* 35 */ /* 36 */ SubmenuIButt[ButtonNumber].Down = 1; // Change the button state to Down;
Assume that:
NrOfButtons == 11SubmenuIButt[0].NoDown == trueSubmentIButt[/* 1..10 */] == falseMsDevice.X > SubmenuIButt[0].LeftEdge == trueMsDevice.X < SubmenuIButt[0].RightEdge == trueMsDevice.Y > SubmenuIButt[0].UpperEdge == trueMsDevice.Y < SubmenuIButt[0].LowerEdge == true(MsDevice.X > SubmenuIButt[/* 1..10 */].LeftEdge && MsDevice.X < SubmenuIButt[/* 1..10 */].RightEdge && MsDevice.Y > SubmenuIButt[/* 1..10 */].UpperEdge && MsDevice.Y < SubmenuIButt[/* 1..10 */].LowerEdge) == falseMsDevice.LBDown == truethis->ID == 700
Now we call SubMenuIClass::Update. The conditional on line 3 is true so we print "!!!!!New update for GShapes submenu \n ". The conditionals on line 8 and lines 10-12 are also true, so we print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Menu button should go down now!!!! \n ". Now we start looping for the first iteration ButtonNumber is 0. The conditional on line 22 is false and so we continue to the next iteration of the loop. For all remaining iterations (ButtonNumber = 1..10) the conditionals on lines 22 and 24 are true, so we print "Ready to evaluate Interface button state \n " once on each of the ten iterations. The conditional on lines 27-29 on the otherhand is always false, so we never hit the conditional on line 31 and therefore never print "This message never gets printed".
Enigma