HighDots Forums  

Looping to check for values

alt.html alt.html


Discuss Looping to check for values in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ll
 
Posts: n/a

Default Looping to check for values - 05-06-2008 , 09:53 AM






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

Reply With Quote
  #2  
Old   
Adrienne Boswell
 
Posts: n/a

Default Re: Looping to check for values - 05-06-2008 , 09:34 PM






Gazing into my crystal ball I observed ll <barn104_1999 (AT) yahoo (DOT) com>
writing in news:213aba9e-3c22-4d3c-ad26-
8f2be175d52f (AT) x35g2000hsb (DOT) googlegroups.com:

Quote:
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)




--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share



Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.