| re: getting file Name
Bob Lehmann wrote:[color=blue]
> WOW! And to think it could have been done in only 3 lines instead.[/color]
Or two:
for (var v=Request.ServerVariables,e=new
Enumerator(v),a=[],s="";!e.atEnd();e.moveNext()){s=String(e.item()); a.push("
["+s+"] "+v(s))}
<%=a.join("<BR>")%>
Why not one?
<%=Request.ServerVariables%>
Of course, neither of these breaks out the cookies and their keyed
name/value pairs into separate line items as my posted example does.
But I suppose you think an example must be written anew each time a question
is to be answered, rather than lifted from any utility scripts we may have
lying around. I confess I am not fond of leaving markup in my examples, but
I considered it relevant in this case.
[color=blue]
> Nice job.
>
> Bob Lehmann
> Verbose, overly-complex code will be read at a cost of $500 per line.[/color]
Whatever. If push/join/replace is complex, then sue me.
[color=blue][color=green]
>> function showServerVariables() {
>> var v = Request.ServerVariables,
>> e = new Enumerator(v),
>> a = new Array(),
>> s = new String()
>> for (; !e.atEnd(); e.moveNext()) {
>> s = String(e.item())
>> if (!/^ALL/.test(s))
>> a.push(
>> "<TD><B>" + s + "</B></TD>" +
>> "<TD>" + split(v(s)) + "</TD>"
>> )
>> }
>>
>> return "<TABLE><TR VALIGN=\"top\">" +
>> a.join("</TR>\r\n<TR VALIGN=\"top\">") +
>> "</TR>\r\n</TABLE>"
>>
>> function split(item) {
>> item = String(item)
>> return item.replace(
>> /([;\n])/g,"$1<BR>"
>> ).replace(
>> /(,)/g,"$1 "
>> ).replace(
>> /(&)/g,"&<BR> "
>> )
>> }
>> }
>>
>> <%=showServerVariables()%>[/color][/color]
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting. |