Looping to check for values

L

ll

I'm working in ASP, and I'm trying to refine a site I inherited. In
particular, there was code that looked like this (it checked for 15
different variables, doing it one at a time, "hardcoded," rather than
through a loop):

'-----------------------------------------------------------
if strOut1 <> "" then
If strOut1 = "N/A" then
strOut1 = "&nbsp; "
else
strOut1 = strOut1 & ","
end if
end if


if strOut2 <> "" then
If strOut2 = "N/A" then
strOut2 = "&nbsp; "
else
strOut2 = strOut2 & ","
end if
end if
'-----------------------------------------------------------

.....and so on.........until we get to strOut15

I'm looking at doing this through a loop and was wondering what the
best way would be? Here's what I have so far:

'-----------------------------------------------------------
for a=1 to 15
if "strOut"&a <> "" then
If "strOut"&a = "N/A" then
strOut(a)="&nbsp;"
else
strOut(a) = "strOut"&a & ","
end if
else
strOut(a) = ""
end if
next
'-----------------------------------------------------------

Thanks for any help. Regards - Louis
 
A

Adrienne Boswell

Gazing into my crystal ball I observed ll <[email protected]>
writing in (e-mail address removed):
I'm working in ASP, and I'm trying to refine a site I inherited. In
particular, there was code that looked like this (it checked for 15
different variables, doing it one at a time, "hardcoded," rather than
through a loop):

'-----------------------------------------------------------
if strOut1 <> "" then
If strOut1 = "N/A" then
strOut1 = "&nbsp; "
else
strOut1 = strOut1 & ","
end if
end if


if strOut2 <> "" then
If strOut2 = "N/A" then
strOut2 = "&nbsp; "
else
strOut2 = strOut2 & ","
end if
end if
'-----------------------------------------------------------

....and so on.........until we get to strOut15

I'm looking at doing this through a loop and was wondering what the
best way would be? Here's what I have so far:

'-----------------------------------------------------------
for a=1 to 15
if "strOut"&a <> "" then
If "strOut"&a = "N/A" then
strOut(a)="&nbsp;"
else
strOut(a) = "strOut"&a & ","
end if
else
strOut(a) = ""
end if
next
'-----------------------------------------------------------

Thanks for any help. Regards - Louis

This is really off topic for this group, better to ask in
microsoft.public.inetserver.asp.general - followups set.

You can write a function eg:

function findout(string)
if string <> "" then
If strOut1 = "N/A" then
strOut1 = "&nbsp; "
else
strOut1 = strOut1 & ","
end if
end if
else
strout1 = string
end if

findout = strout1

end function

Then use the function eg:
response.write findout(variable)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top