Condensing my code…

This one falls under the “code that makes me” smile category (that I don’t have on the blog), but it’s more about making three lines of code into one…

I have a script that converts the contents of a textbox into several sentences as opposed to one large paragraph as form/database uploads tend to natively. It basically take hidden characters (chr13, control code for carriage return) and converts them into the equivalent html thus;

<% para =(rs1.Fields.Item(“detail”).Value)%>
<% para = replace(para, chr(13), “<br>” ) %>
<% response.write (para) %>

Nice and simple, line one puts the detail field into a varaiable (para), line two replaces the control code chr13 with “<br>” and line three outputs it to the screen.

This afternoon in a flash of clarity I concocted the following;

<% response.write replace((rs1.Fields.Item(“detail”).Value), chr(13), “<br>” ) %>

Which accomplishes exactly the same thing with only the one line of code.

Like I said, makes me smile….

By the way, it may look like all I do is code, but that’s not true, I am an actual IT Manager too, just working in a department that is too poor to fund a full-time coder!

3 thoughts on “Condensing my code…

Leave a Comment

THE PERSONAL BLOG OF CORNWALL-BASED COMPANY DIRECTOR // CHRIS RICKARD