@q
@program dtog.muf
1 99999 d
i
( dtog.muf   v1.0    Jessy @ FurryMUCK    8/99
  
  This is a very simple utility, but it saves me a considerable number
  of keystrokes. Instead of typing @set <program>=D and @set
  <program>=!D repeatedly, I enter the program I'm working with
  once...  afterwards, the command name by itself toggles the program's
  Debug flag.

  INSTALLATION:

  Link an action -- global or local -- to the program. I use a short
  command name like 'dd'.

  USAGE:

    <command> <program> .... Set <program> as current program
    <command> .............. Toggle <program>s Debug flag.

  dtog.muf may be freely ported. Please comment any changes.
)
 
: DoHelp
  
  " " .tell
  prog name " (#" strcat prog intostr strcat ")" strcat .tell " " .tell

  "This utility toggles the Debug flag of whatever program you last set."
  .tell " " .tell

  command @ " <program> ......... Set <program> as current program."
  strcat .tell
  command @ " ................... Toggle current program's Debug flag."
  strcat .tell
;
  
: main
  
  dup if
    "#help" over stringpfx if
      DoHelp exit
    then
    match dup if
      dup program? if
        me @ over controls if
           me @ "_prefs/dtog" 3 pick setprop
     ">>  " swap name strcat
     " is now your dtog program." strcat .tell
  else
    ">>  Sorry, you don't control that program." .tell
  then
      else
         ">>  That's not a program." .tell pop
      then
    else
      ">>  Program not found." .tell
    then
  else
    me @ "_prefs/dtog" getprop dup if
      dup ok? not if
        ">>  You need to set a program to toggle." .tell pop exit
      then
      dup "D" flag? if
        "!D" set
  ">>  Program set !Debug." 
  me @ "_prefs/dtog" getprop name "Program" subst 
  .tell
      else
        "D" set
  ">>  Program set Debug."
  me @ "_prefs/dtog" getprop name "Program" subst 
  .tell
      then
    else
      ">>  You need to set a program to toggle." .tell pop
    then
  then
;
.
c
q