Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple? asp question regarding <% %> syntax : is more better? 2

Status
Not open for further replies.

puterdude

Technical User
Apr 13, 2001
51
0
0
US
Hi,

I'm a newbie. I have multiple lines of asp code:
ie.

<% if inStr(myvar,&quot;A&quot;) then Response.write(&quot;selected&quot;) End if %>
<% if inStr(myvar,&quot;B&quot;) then Response.write(&quot;selected&quot;) End if %>
<% if inStr(myvar,&quot;C&quot;) then Response.write(&quot;selected&quot;) End if %>

Would it be better to use only one set of brackets?

<%
if inStr(myvar,&quot;A&quot;) then Response.write(&quot;selected&quot;) End if
if inStr(myvar,&quot;B&quot;) then Response.write(&quot;selected&quot;) End if
if inStr(myvar,&quot;C&quot;) then Response.write(&quot;selected&quot;) End if
%>

Thanks,

PuterDude
 
Is better the second way for the computer, It's more easy to read and execute. Thanks.
SunStorm
 
Just to expound a little,
the second way is better because it reduces the amount of context switching for the CPU. by reducing the amt of context switching, the webserver CPU works more efficiently.

Other things that you might want to keep in mind:
String concatentation in VB is VERY slow... try to keep string concat to a minimum.

If you have multiple response.writes, combine them all into one long response.write. It reduces the amount of funciton calls that you need to make, but by using the _ you don't need to lose much readablity.

just trying to help
leo
 
Thanks everyone. Really helped.
Not sure what you mean about the concatenation. I know what it is, I just don't know what you mean about one long write.
I'm using jmail and I have to concantenate to get what I want. Seems to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top