|
looks like a basic dialect from out of the legendary Bill Gates times.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
|
So he found the right forum.
To be honest: tons of old code are running: in banks , factories, (nuclear) plants or goverments agencies. They have often a problems finding the code and a maintainer, like COBOL.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
This is the base code vs generates to check for special keys, on a Smart Device project:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Left))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
}
}
A Pocket PC is full of power, so let's check for every possible key.
|
|
|
|
|
I don't see any horror here. What do you want to do if you need to check for those keys?
|
|
|
|
|
If the first if is true, for example, why bother testing all the others which follow? It's dopey code.
Steve
|
|
|
|
|
some else if would be much better indeed, and the switch/case would be even more appropriate for this stuff, but still it doesn't real shock me.
|
|
|
|
|
That many bunch of if s could have been elegantly presented with a decent switch block.
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!
|
|
|
|
|
It's not a big horror, its just funny to see it on Visual Studio. The correct implementation would be:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch(e.KeyCode)
{
case System.Windows.Forms.Keys.Up:
break;
case System.Windows.Forms.Keys.Down:
break;
case System.Windows.Forms.Keys.Left:
break;
case System.Windows.Forms.Keys.Right:
break;
case System.Windows.Forms.Keys.Enter:
break;
}
}
|
|
|
|
|
it is a horror that this visible code is so poor.
What about the non-visible code. Shame on Microsoft!!!
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Invisible code ?!?? Where ??
|
|
|
|
|
I mean the code we cant look at, like the soruce code of windwos or Office.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: we cant look at, like the soruce code of windwos or Office
But we can feel it and enjoy it with timely patches and service packs.
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!
|
|
|
|
|
Now I am feeling the difference between Version "6.0" and "6.1 RC" of a wellknown Microsoft product. I feel that they really work hard and encouraged.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Maybe he doesn't understand the Spanish.
Vita est usquequaque virtus victus ut plenus. Ego non sum semper iustus tamen Ego sum nunquam nefas!
|
|
|
|
|
Ah, but this way there's a nice little hack brewing. Modify the parameters in some ASM code mid-execution, and you can invoke multiple segments of code. That way, there's two operating modes built in - cracker and normal user. Crackers can have super-special zero-bug privileges, while normal users can get walloped with the bug-hammer
Of course, a nice little service running in the background on the target machines can do this automatically. Maybe a clause can be put in which stops modifying the code if certain packets are received. Grumpy, abusive user gets bugs, rich user with lots of contacts gets fewer
|
|
|
|
|
You would delete the auto-generated code anyway wouldn't you?
Actually isn't there a file (or files) that contain such things and you can change them there?
|
|
|
|
|
PIEBALDconsult wrote: You would delete the auto-generated code anyway wouldn't you?
Actually isn't there a file (or files) that contain such things and you can change them there?
Of course, I can change the code, the same way you would change the code on all the horrors published here. Isn't this forum to publish horrors you find over there?
I think this is a reply horror.
|
|
|
|
|
This might not be a horror at all.
Maybe it's intended this way (I don't know as I never used a Pocket PC).
If the user presses multiple directions, several if s are true and the code for each of them should be executed.
Otherwise diagonal directions would be impossible because it would accept only a single directional key at once.
|
|
|
|
|
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.
|
|
|
|