Bracket matching bug
Displaying 1-5 of 5 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Overkill

I've just discovered that the following code:

void TextBox(string a, string b, string c) // Textbox("Blah blah blah")
{
int done; // To tell when we're done.
while (!done) // While not done... loops this code.
{
// Draw the map.
Render();
// Draw a Box.
DrawWindow(5, 5, ImageWidth(screen) - 5, 15 + (FontHeight(0) * 3), screen);
// Draw the text.
PrintString(10, 10, screen, 0, a);
PrintString(10, 10 + (FontHeight(0) * 1), screen, 0, b);
PrintString(10, 10 + (FontHeight(0) * 2), screen, 0, c);
// An essential to any loop. Refreshes the screen.
// Only do after you draw everything.
ShowPage();

if (b1) // If we press button 1, enter.
{
done = 1; // We're done.
Unpress(1); // Make sure they let go of b1.
}
}
}

Can be represented as the following if it's the last function in the file:

void TextBox(string a, string b, string c) // Textbox("Blah blah blah")
{
int done; // To tell when we're done.
while (!done) // While not done... loops this code.
{
// Draw the map.
Render();
// Draw a Box.
DrawWindow(5, 5, ImageWidth(screen) - 5, 15 + (FontHeight(0) * 3), screen);
// Draw the text.
PrintString(10, 10, screen, 0, a);
PrintString(10, 10 + (FontHeight(0) * 1), screen, 0, b);
PrintString(10, 10 + (FontHeight(0) * 2), screen, 0, c);
// An essential to any loop. Refreshes the screen.
// Only do after you draw everything.
ShowPage();

if (b1) // If we press button 1, enter.
{
done = 1; // We're done.
Unpress(1); // Make sure they let go of b1.
}

Posted on 2006-02-01 06:22:59

yhnmzwcs

Can the bracket for 'if' be accidentally omitted too?

The concept of an open 'while' loop is more worrisome than an unended 'if'.

Posted on 2006-02-01 17:04:58

Overkill

Nope, it only works for those two, and when I try making the if() into an open while, it also doesn't work. But it's disturbing since that encourages bad coding habits, the worst of the worst, not having all brackets.

Posted on 2006-02-01 17:51:14

CrazyAznGamer

=*(
That's bad. Now, new people may get in the habit of not closing brackets, and then, because brackets are not closed, millions of babies will die world-wide...
...
Somebody start diggin'.

Posted on 2006-02-03 22:52:14

Omni

Isn't it possible this could be one of those self-fulfilling prophecy things? I myself would never intentionally write bad code as I'm sure it plain doesn't work right.

...But the minute you discover that it does indeed work...

Posted on 2006-02-05 12:04:22


Displaying 1-5 of 5 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.