Message-Id: <9304011900.AA28358@acs6.acs.ucalgary.ca>
Subject: Re: Stylistic Comments
Date: Thu, 1 Apr 93 12:00:19 MST
From: Joshua Sean Bell <jsbell@acs.ucalgary.ca>

u9228616@athmail1.causeway.qub.ac.uk writes:

> Thanks very much Josh for those small hints that you posted.

You're welcome!

> Thanks also to Lydia! I will try to space my code properly *8)

This is something I should learn to do. Growing up on Applesoft
Basic is good training for writing obfuscated code. Oddly, I do
all offline anyway, and examine the in-MUSH code with the +pex
thingy, so I usually don't bother.

> Up until now I wasn't aware of the things you pointed out *blush*

> o I have the code for a Pretty Examiner that was posted on this
>   list a while back. But when I go to examine anything it says
>   that I can't examine that!

>   I copied the code exactly! Can anyone tell me what I am doing
>   wrong or whether the code was faulty or not! If the code was
>   faulty then could the person responsible for it repost a correct
>   version or post it to me! Thanks!

At the end of this post is a @decompile of the NarniaMUSH Pretty
Lister object. I just looked at the CAN_EX code, and it should be
able to be used by non-wizards. Things to check:

	- Are you examining things you can normally examine?
	- Did you give it an INHERIT flag, so the locate() can
work properly?
	- Are you on a PennMUSH 1.x system?

Those are the problem spots that spring to mind.

I've noticed that the code I wrote doesn't handle delimited {};s.
Thats not good. Sigh. I think, however, rather than patching it,
I'll crack open the MUSH server and modify the view_atr routine
to do formatting if a /format flag is used with the examine
command. This should be a lot faster, and a lot more robust. If,
of course, I can get the blasted thing to work. Not having a
machine that can compile 2.0.9p1 makes it a pain to test such
code.

Speaking of which, anyone know how to get the darn thing to
compile on AIX 3.2, SunOS 4.1.2, or a DEC Alpha, all of which
gag all over the place...

Anyway, enough rambling, here's the code itself:

@create Pretty Lister
&REDIT Pretty Lister=switch(rest(%1),,edit(%0,%1,%2),u(redit,edit(%0,first(%1),first(%2)),rest(%1),rest(%2)))
&MARK Pretty Lister=switch(rest(%1),,edit(%0,%1,%2%1%2),u(mark,edit(%0,first(%1),%2[first(%1)]%2),rest(%1),%2))
&UNMARK Pretty Lister=switch(rest(%1),,edit(%0,%2%1%2,%1),u(unmark,edit(%0,%2[first(%1)]%2,first(%1)),rest(%1),%2))
&DO_MARK Pretty Lister=u(combine,u(unmark,u(mark,%0,v(symbols-1),<@!@>),v(second),<@!@>),v(symbols-2),<@!@>)
&COMBINE Pretty Lister=switch(rest(%1),,edit(%0,[mid(%1,0,1)]%2%2[mid(%1,1,1)],%1),u(combine,edit(%0,[mid(first(%1),0,1)]%2%2[mid(first(%1),1,1)],first(%1)),rest(%1),%2))
&FORMAT Pretty Lister=[repeat(%t,%1)][before(%0,<@!@>)][switch(u(symbol,%0),\}\;,%r[repeat(%t,%1)]\}\;%r[u(format,u(rest,%0),sub(%1,1))],\}\,,%r[repeat(%t,%1)]\}\,%r[u(format,u(rest,%0),sub(%1,1))],\,\{,\,\{%r[u(format,u(rest,%0),add(%1,1))],\;,\;%r[u(format,u(rest,%0),%1)],\:,:%r[u(format,u(rest,%0),%1)],\{,%r[repeat(%t,add(1,%1))]\{%r[u(format,u(rest,%0),add(%1,1))],\},%r[repeat(%t,%1)]\}%r[u(format,u(rest,%0),sub(%1,1))],\,,\,%r[u(format,u(rest,%0),%1)],,%r[u(rest,%0)])]
&SYMBOL Pretty Lister=before(after(%0,<@!@>),<@!@>)
&REST Pretty Lister=after(after(%0,<@!@>),<@!@>)
&PRETTY_LIST Pretty Lister=u(remove_trailing,u(format,u(do_mark,%0),1))
&FIRST Pretty Lister=; : { } ,
&SECOND Pretty Lister=\{ \} \; \,
&SYMBOLS-1 Pretty Lister=; { }
&SYMBOLS-2 Pretty Lister=};
&PEX_FORMAT Pretty Lister=switch(%0,$*,%1:[before(%0,:)]:%r[u(pretty_list,after(%0,:))],^*,%1:[before(%0,:)]:%r[u(pretty_list,after(%0,:))],@*,%1:%r[u(pretty_list,%0)],&*,%1:%r[u(pretty_list,%0)],%1:%0)
&PEX Pretty Lister=$+pex */*:@switch u(can_ex,%#,locate(%#,%0,*))=0,{@pemit %#=You can't examine that!},2,{@pemit %#=I don't see that here.},{@dolist lattr(locate(%#,%0,*)/%1)=@pemit %#=u(pex_format,get(locate(%#,%0,*)/##),##)}
&PEX_A Pretty Lister=$+pex *:@switch %0=*/*,,{@switch u(can_ex,%#,locate(%#,%0,*))=0,{@pemit %#=You can't examine that!},2,{@pemit %#=I don't see that here.},{@pemit %#=u(header,locate(%#,%0,*));@dolist lattr(locate(%#,%0,*))=@pemit %#=u(pex_format,get(locate(%#,%0,*)/##),##);@fo me=@pemit %#=u(footer,locate(%#,%0,*))}}
&REMOVE_TRAILING Pretty Lister=switch(%0,*%r,u(remove_trailing,mid(%0,0,sub(strlen(%0),2))),*%b,u(remove_trailing,mid(%0,0,sub(strlen(%0),1))),*%t,u(remove_trailing,mid(%0,0,sub(strlen(%0),1))),%0)
@Desc Pretty Lister=Wiz-types: Use pex <object>\[/<attribute>\] to pretty-examine something. Anything starting with $ @ or & gets formatted. Comments --> Tash@NarniaMUSH
&CAN_EX Pretty Lister=switch(1,hasflag(%1,visual),1,strmatch(%0,owner(%1)),1,hasflag(owner(%0),wizard),1,strmatch(%1,#-1),2,0)
&HEADER Pretty Lister=[u(unparse,%0)]%rType: [type(%0)] Flags: [u(flags,%0)]%rOwner: [name(owner(%0))] %b Money: [money(%0)][u(locks,%0)]
&LOCKS Pretty Lister=iter(DefaultLock EnterLock GiveLock LeaveLock LinkLock PageLock ReceiveLock TeloutLock TportLock UseLock,switch(lock(%0/##),,,%r##: [lock(%0/##)]))
&HELP Pretty Lister=$+help pex:@pemit %#=u(help_pex)
&HELP_PEX Pretty Lister=%b Command: +pex <object>[/<attribute-pattern>]%r%b Pex is short for "Pretty Examine", which takes standard MUSH code %r%b and displays it with C-like formatting. The +pex command is an%r%b alternative to the standard MUSH "examine" command, and operates%r%b identically, except that any attribute starting with $, ^, @ or &%r%b is assumed to represent MUSH code. Beware of the following:%r%b %t- Attribute Flags and Locks are NOT displayed.%r%b %t- Efforts have been made to ignore backslash-delimited%r%b %t %bsemicolons and braces. No promises are made, however.%r%b %t- You can only examine an object if you own it, it is %r%b %t %bvisual or you (or your owner) is a Wizard. %r%b Example:%r%b > +pex #100/example%r%b EXAMPLE:$test *:%r%b %t@switch %%0=a,%r%b %t%t\{%r%b %t%t@pemit %%#=You typed 'test a'!;%r%b %t%t\};%r%b %t&register me=%%0
&FOOTER Pretty Lister=[switch(type(%0),exit,Source:,Home:)] [u(unparse,home(%0))]%r[switch(type(%0),exit,Destination:,Location:)] [u(unparse,loc(%0))]
&UNPARSE Pretty Lister=[fullname(%0)](%0[flags(%0)])
&FLAGS Pretty Lister=iter(iter(ABODE AUDIBLE BUILDER CHOWN_OK CONNECTED DARK DESTROY_OK ENTER_OK FLOATING GOING HALTED HAVEN INHERIT JUMP_OK KEY LINK_OK MONITOR MYOPIC NOSPOOF OPAQUE PARENT_OK PUPPET QUIET ROBOT ROYALTY SAFE SLAVE STICKY SUSPECT TEMPLE TERSE TRANSPARENT UNFINDABLE VERBOSE VISUAL WIZARD ZONE,switch(hasflag(%0,##),1,##)),##)
@set Pretty Lister=INHERIT


Joshua
|"The universe is simply one of those things that happens from time to time."|
|                                                   - Edward Tyron           |
| jsbell@acs.ucalgary.ca  Academic Computing Services, University of Calgary |
