Simple Debugger

version 1/080105 by Michael Hilborn

  • Home page
  • Beginning
  • Previous



  • Section 3 - Verbs - Not for release

    [Now we'll define our actions. There are two commands a player may type: "debug", which turns all object-debugging on, and "debug [something], which activates the debugging properties of only that particular object. First, we define the "debug" command.]
    General debugging is an action applying to nothing.

    Understand "debug" as general debugging.

    Carry out general debugging:
        set general debugging "on".

    [And now we'll define the "debug [something]" command.]
    object-debugging is an action applying to one thing.

    Understand "debug [any thing]" as object-debugging.

    [Remember, we want to be able to debug objects that the player can't touch, see, etc. So before we debug an object, we need to ignore Inform's standard accessibility rules.]
    Before object-debugging:
        ignore the basic accessibility rule.

    Carry out object-debugging:
        if the noun is being debugged begin;
            now the noun is not being debugged;
            say "No longer debugging [the noun].";
        otherwise;
            now the noun is being debugged;
            say "Debugging [the noun]. Type 'debug [the noun]' to turn it off.";
        end if.

    [We also want the debug command to operate like the internal Inform 7 utilities; that is, "debug" and "debug on" both activate general debugging, and "debug off" turns it off.]
    Debugging with option is an action applying to one topic.

    Understand "debug [text]" as debugging with option.

    [On a personal note, I hate this if..., if..., if... syntax, but this seems to be a limitation of using natural language--or, perhaps, a limitation of a professional programmer attempting to write with a natural language.]
    Carry out debugging with option:
        if the player's command matches "debug on" begin;
            set general debugging "on";
            rule succeeds;
        end if;
        if the player's command matches "debug off" begin;
            set general debugging "off";
            rule succeeds;
        end if;
        if the player's command matches "debug things" or the player's command matches "debug things on" begin;
            set debugging for all objects "on";
            rule succeeds;
        end if;
        if the player's command matches "debug things off" begin;
            set debugging for all objects "off";
            rule succeeds;
        end if;
        if the player's command matches "debug everything" or the player's command matches "debug everything on" begin;
            set ultra debugging "on";
            rule succeeds;
        end if;
        if the player's command matches "debug everything off" begin;
            set ultra debugging "off";
            rule succeeds;
        end if;
        say "You entered an invalid debug option. Valid commands are 'debug', 'debug [bracket]on|off[close bracket]', 'debug things [bracket]on|off[close bracket]', 'debug [bracket]thing[close bracket]', and 'debug everything [bracket]on|off[close bracket]'".



    Simple Debugger ends here.