( Can be called as: @mpi - similar behaviour to @mpi @xmpi - prints brace-expanded code, before executing it @xmpi #help - prints a copyright thingy @xmpi #show #1234;_/sc - displays the _/sc property on #1234 {if you own it} Handles both \{ and `}` style escapes. There is a minor bug involving incorrect summary diagnostics, but the indentation code makes that unimportant. Copyright 1999 Tim Baverstock {Warwick/FurryMUCK}. May be distributed under the GPL so long as these lines remain with it. New versions may appear at http://www.sable.demon.co.uk/muf ) : st ( -- ) ( Stack trace ) depth "( " begin over while over 2 + pick dup string? not if intostr then strcat " " strcat swap 1 - swap repeat ")" strcat me @ 2 put notify ; : itell ( s i -- ) over not if pop pop exit then dup 0 < if intostr "** " strcat else " . . . . . . . . . . . . " swap 4 + strcut pop then swap strcat me @ swap notify ; : escinstr ( s sub -- i ) ( Any \x? Return vanilla instr if not ) over "\\" instr dup not if pop instr exit then 1 + ( Any sub? ) 3 pick 3 pick instr dup not if pop pop pop pop 0 exit then ( Return sub if it's earlier than \x ) over over > if 3 put pop pop exit then ( Remove up to and including \x ) pop rot over strcut swap pop rot ( Look again for sub, adding amount removed or returning 0 ) escinstr dup if + else swap pop then ; : quinstr ( s sub -- i ) ( Any `? Return vanilla escinstr if not ) over "`" escinstr dup not if pop escinstr exit then ( Any sub? ) 3 pick 3 pick escinstr dup not if pop pop pop pop 0 exit then ( Return sub if it's earlier than ` ) over over > if 3 put pop pop exit then ( Remove up to and including ` ) pop rot over strcut swap pop rot ( Look for the matching `, returning 0 if unfound ) over "`" escinstr dup not if pop pop pop pop 0 exit then ( Remove up to and including second ` ) rot over strcut swap pop rot ( Look again for sub, adding amount removed or returning 0 ) quinstr dup if + + else swap pop swap pop then ; : indent ( i s -- i s ) begin dup while ( Find first { } or , character in remaining string ) dup "{" quinstr dup not if pop dup strlen 1 + then swap dup "}" quinstr dup not if pop dup strlen 1 + then rot over over > if swap then pop swap dup "," quinstr dup not if pop dup strlen 1 + then rot over over > if swap then pop ( Isolate { } or , character ) 1 - strcut 1 strcut ( Print remainder and exit if isolated character is empty ) over not if pop pop over over swap itell exit then ( Print indented first section of cut string ) rot 4 pick itell ( Indent increases at { ) over "{" strcmp not if strcat dup "}" quinstr dup not if pop dup strlen then swap dup ":" instr dup not if pop dup strlen then rot ( Handle {&argv} type things, sans colon, with no indent ) over over > if swap pop strcut swap 3 pick itell else ( Indent for {tell:this} type things, avec colon ) pop strcut swap 3 pick itell swap 4 + swap then ( Indent decreases at } ) else over "}" strcmp not if swap rot 4 - dup -4 rotate itell else ( Indent doesn't change at , but you do get a line break ) over "," strcmp not if swap 3 pick itell else over itell "" exit then then then repeat ; lvar db lvar prop : main dup "#help" strcmp not if me @ "@xmpi - bracket matching MPI execution program" notify me @ "(c)September 1998 Warwick@FurryMuck" notify me @ "Last MPI string is used as default if no string given" notify me @ "@xmpi #show object;property uses that; _/sc is @succ" notify exit then dup "#show" 5 strncmp not if 5 strcut swap pop strip dup ";" instr dup not if pop dup ":" instr dup not if me @ "** Separate object from property with ; or :" notify exit then then 1 - strcut 1 strcut swap pop prop ! 1 strcut over "#" strcmp not if swap pop atoi dbref else strcat match then dup owner "me" match dbcmp not if me @ "** Not owner, or ambiguous or invalid object reference." notify exit then db ! 1 else dup if me @ "_/mpi" rot setprop else pop then me @ db ! "_/mpi" prop ! 0 then db @ prop @ command @ 1 parseprop swap if me @ "Object: " db @ name strcat notify me @ "Property: " prop @ strcat notify then me @ "Command: " db @ prop @ getpropstr strcat notify command @ "@mpi" strcmp if 0 db @ prop @ getpropstr indent pop if me @ "** Bracket mismatch" notify then then " Result: " swap strcat me @ swap notify ;