|
Megidolaon wrote: If the user presses multiple directions
Then multiple events are fired.
|
|
|
|
|
...yes, thatwould be true
|
|
|
|
|
Even if multiple keys where able to be captured at the same time, using many == will not be a solution.
After all, if the keys where combined using the | operator, as happens with flags, the right way to check the values will be using: if ((parameter & condition) == condition) or if ((parameter & condition) != 0)
But that's not the case with keys. So, this is an ugly code (but not an horror in my opinion).
|
|
|
|
|
adgonz wrote: multiple events are fired.
The application goes haywire and user runs amuck helter-skelter.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
I think my VS is broken or something.
I get an error for not writing a return after a catch block.
The method in question:
private bool ReadIni()
{
try
{
[do stuff]
if ([error string != "" || string array with file content == null])
{
[return false; among other things]
}
else
{
[return true; among other things]
}
}
catch (Exception ex)
{
[display error message]
}
return false
}
|
|
|
|
|
This is not an error at all...
If an exception would occur in the if-condition, the resulting control flow would be without any return statement. So the compiler error is nothing but correct. No broken VS, just malformed code...
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Why wouldnt you return something from the function declared
private bool ReadIni();
|
|
|
|
|
My guess is that you then can do something like:
if (ReadIni())
{
}
else
{
}
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
to validate the if statement the funtion WOULD return a bool type......
which was my point
WTF is going on here
|
|
|
|
|
Code similar to this would produce a warning in VC++ that not all execution paths have a return statement. In the catch block, there's the possibility the code could continue past the catch block, thus reaching the end of the function, so it'd look as if the function didn't have a return statement at the end for a function with a return time other than void.
|
|
|
|
|
As I said, a horropr made by me.
I just realized that it has to be this way.
I guess that's what ages opf windows forms programming with only void methods can do to you, you forget the basics of functions. 
|
|
|
|
|
Nothing horrible like using enums or flags as case values, no, we preserve the whole JOIN clause,
as issued from some vile marriage between combo box and literals.
Yes, the strSQLJOIN value is chosen as a SelectedValue of a combo!
There are eight cases, this being the last. The first only includes Level1.
switch (strSQLJOIN)
{
.
.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN Level3 ON Level2.LevUp_ID = Level3.Lev_ID LEFT JOIN Level4 ON Level3.LevUp_ID = Level4.Lev_ID LEFT JOIN Level5 ON Level4.LevUp_ID = Level5.Lev_ID LEFT JOIN Level6 ON Level5.LevUp_ID = Level6.Lev_ID LEFT JOIN Level7 ON Level6.LevUp_ID = Level7.Lev_ID LEFT JOIN Level8 ON Level7.LevUp_ID = Level8.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
detailSelectList = "select Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName;";
break;
|
|
|
|
|
Well, that is what you can get when applying the principles of self-documenting code.
|
|
|
|
|
*Attempted to write a reply but got a heart attack while having a second look at the code*
Cheers
BN
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
I have to say that is the worst switch statement that I have ever seen and I have seen some pretty bad ones
Bill W
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Brady Kelly wrote: Switch Statement from Hell
You were NOT exaggerating!
|
|
|
|
|
Thank God! There are only 8 levels!!
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
What about the other case statements?
I'm curious now!!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
OK, that was the last one, here are the first two.. You should be able to infer the rest.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
strSQL = strSQL + "Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName;";
break;
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
strSQL = strSQL + "Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName;";
break;
You really gotta try harder to keep up with everyone that's not on the short bus with you.
- John Simmons / outlaw programmer.
|
|
|
|
|
I see, mmm...
Really the original programmer should have foreseen the problem and use Emit to dynamically generate/compile a method for an ever increasing number of case!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Super Lloyd wrote: A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
I want to steal your signature!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Ho no... I already stole it from someone else, you can't steal it from me!!!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
if(guess == random)
{
printf("\nExcellent! You guessed the number!\nWould you like to play again?(y/n)");
scanf("%c",&play);
if(play == 'n')
{
game = 0;
}
}
else
{
if(guess < random && guess != random)
{
printf("\nToo low, try again!");
}
if(guess > random && guess != random)
{
printf("\nToo high, try again!");
}
}
Reference[^]
Parag Patel
Sr. Software Eng, Varaha Systems
|
|
|
|
|
if(guess < random && guess != random)
{
printf("\nToo low, try again!");
}
if(guess > random && guess != random)
{
printf("\nToo high, try again!");
}
nice...
my guess would be: never trust a computer...
(yes|no|maybe)*
|
|
|
|
|
It's just to easy to imagine this person is now bragging about his program and trying to impress others with his coding skills - lol.
|
|
|
|