Lurker News

Comments (169) 37 threads

Show all comments

Showing thread 11 of 37

ifdefdebug4 replies#
Indeed some deep nesting here. You made me remember a quickbasic program I wrote for a class back in early 90s, where I packed the whole program in a single do-loop with about 20 indent levels at it's deepest, and I loved it. But... the prof told me to never do that again :( Anyway, thanks a lot for the flashback :)
RyanRies2 replies#
Agreed, it's not the most elegant code, but it's so short and simple I haven't bothered reorganizing the code yet. I probably will start adding features like re-bindable pause key, etc., and I will untangle the mess a bit at that time.
asddubs#
quickest way to do it is to negate your if conditions in the loop something like this:

    if (ForegroundWindow)
    {
        ...
    }
    else
    {
        MessageBox(NULL, L"Unable to detect foreground window!", L"UniversalPauseButton Error", MB_OK | MB_ICONERROR);
    }
becomes

    if (!ForegroundWindow)
    {
        MessageBox(NULL, L"Unable to detect foreground window!", L"UniversalPauseButton Error", MB_OK | MB_ICONERROR);
        break;
    }
    ...
meritt1 reply#
Deep nesting always bugs me too. It's so much cleaner and easier to understand (for me anyway) to identify the else case ahead of time and stop processing immediately.
RyanRies#
Alright, should be pretty much taken care of in version 1.0.1.