Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Calling include files in response.write, or do while loops

Reply
Thread Tools

Calling include files in response.write, or do while loops

 
 
.Net Sports
Guest
Posts: n/a
 
      03-15-2005
I want to include some asp if statements inside a do until loop,
predicated on the recordset going until EOF. I do not have any < % %>
delimiters inside the include file. The below doesnt show the character
I want to display:

<% do until rs.eof
response.write rs("position")
<!-- #include file="inc_.asp" -->
loop %>

...while hard coding the character with another response.write statement
will.

Thanks for any insights
..net sports

 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      03-15-2005
Well, first off, I don't see an rs.movenext, nor do you break out of <% %>
to call the #include file (<!--#include does not belong inside <% %>
delimiters!). See what happens when you change it to:

<%
do WHILE NOT rs.eof
response.write rs("position")
%>
<!-- #include file="inc_.asp" -->
<%
rs.movenext
loop
%>

Next, why not #include a file once (or not at all), and have a function.
Then not only will you avoid having this #include file referenced 8000
times, you can also make the function respond directly to differences
between rows in your resultset. Much smoother architecture that way...

e.g.

inc_.asp

<%
function writeCharacter()
response.write "bleh"
end function
%>

Now your loop becomes:

<%
do while not rs.eof
response.write "<br>" & rs("position")
writeCharacter()
rs.movenext
loop
%>

I don't see the point of repeating an #include directive n times with the
same file, it doesn't seem to make sense to me at all.

--
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.




".Net Sports" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I want to include some asp if statements inside a do until loop,
> predicated on the recordset going until EOF. I do not have any < % %>
> delimiters inside the include file. The below doesnt show the character
> I want to display:
>
> <% do until rs.eof
> response.write rs("position")
> <!-- #include file="inc_.asp" -->
> loop %>
>
> ..while hard coding the character with another response.write statement
> will.
>
> Thanks for any insights
> .net sports
>



 
Reply With Quote
 
 
 
 
Jonathan Dodds
Guest
Posts: n/a
 
      03-17-2005
> <%
> do WHILE NOT rs.eof
> response.write rs("position")
> %>
> <!-- #include file="inc_.asp" -->
> <%
> rs.movenext
> loop
> %>


The #include won't be performed N times. It will be performed once. It's a
textual include, not an ASP script command. Nevertheless the point about not
doing this (for other reasons) is well taken.


 
Reply With Quote
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      03-17-2005
Right, important distinction. The file isn't #included n times, but the
code inside is still processed by the ASP engine n times (regardless of
whether it has ASP code or not). If it contains HTML, then that part it is
rendered by the browser n times.

Try this example:

<% for I = 1 to 5 %>
<!--#include file=bar.asp-->
<% next %>

Bar.asp:

<% response.write i & "<p>" %>

All in all, probably not *that* much different from calling a function, but
much more difficult to manage, IMHO.





On 3/16/05 11:11 PM, in article http://www.velocityreviews.com/forums/(E-Mail Removed),
"Jonathan Dodds" <NO_REPLY> wrote:

>> <%
>> do WHILE NOT rs.eof
>> response.write rs("position")
>> %>
>> <!-- #include file="inc_.asp" -->
>> <%
>> rs.movenext
>> loop
>> %>

>
> The #include won't be performed N times. It will be performed once. It's a
> textual include, not an ASP script command. Nevertheless the point about not
> doing this (for other reasons) is well taken.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
Testing pointers in while-loops cman C Programming 6 03-03-2007 09:08 AM
for and while loops kydavis77@gmail.com Python 6 06-29-2006 03:40 AM
Loops with loops using html-template Me Perl Misc 2 01-12-2006 05:07 PM
while loops Angie C++ 4 08-01-2003 01:45 PM



Advertisments