In ASP Classic, a very long if statement with multiple [AND]'s and [OR]'s can become unreadable, especially if you constantly add to them.
When your code has a lot of different Queries that show relative information and use the same database statements, you may find yourself using that same connection instead of recreating it. And this is where very long IF and/or THEN statements come into play.
<%
IfgetType="Something"thenresponse.write"Some information here."end if
%>
Now, let us take a look at a more complex statement.
This first code is on one single line. This is an example of what I encountered while developing our new website, which will be released by the end of February 2023. (Link will be provided here once it is LIVE).
ifgetType="One"and getOne<>""and not getOnes<>"" or getType="Two"and getTwo<>""and not getTwos<>"" or getType="Three"and getThree<>""and not getThrees<>"" or getType="Four"and getFour<>""and not getFours<>"" or getType="Five"and getFive<>""and not getFives<>"" or getType="Six"and getSix<>""and not getSixs<>"" or getType="Seven"and getSeven<>""and not getSevens<>"" or getType="Eight"and getEight<>""and not getEights<>""thenresponse.write"Some information here."end if
To make it much easier to work with, I have broken the above single-line string into individual lines, as we will be adding more and more Queries to this IF Statement over time.
In the IF Statement below, we separated each line with an underscore _. This information was found @ copyprogramming.com«.
ifgetType="One"and getOne<>""and not getOnes<>""_
or getType="Two"and getTwo<>""and not getTwos<>""_
or getType="Three"and getThree<>""and not getThrees<>""_
or getType="Four"and getFour<>""and not getFours<>""_
or getType="Five"and getFive<>""and not getFives<>""_
or getType="Six"and getSix<>""and not getSixs<>""_
or getType="Seven"and getSeven<>""and not getSevens<>""_
or getType="Eight"and getEight<>""and not getEights<>""_thenresponse.write"Some information here."end if