Print Page | Close Window

Conditions

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=12123
Printed Date: 29 March 2026 at 3:55pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Conditions
Posted By: theSCIENTIST
Subject: Conditions
Date Posted: 11 October 2004 at 6:38am
Imagine this condition:

If A=A Or B=B Or C=C Or D=D Then

...
...
End If


If I know that only C=C, is it worth to place it first, so the ASP processing don't have to check other conditions first? Or does ASP always reads the whole line anyway?

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com



Replies:
Posted By: Mart
Date Posted: 11 October 2004 at 11:23am
It HAS to read the whole line anyway to see if there are any other conditions that do not hit.

i.e. The ASP Parser does not know you are going to do that so it read the whole line anyway incase theres something like this

Dim C, D
C = "Hello"
D = "Hi"

If (C = C)  And (C = D) Then
...
...
End If



Posted By: theSCIENTIST
Date Posted: 11 October 2004 at 11:32am
Right, yes, it has to check the whole line because there could also be an (And) there, but if it was all (Or's), the parser could run to the next line since there's enough data for the condition to be met, seams wasteful otherwise.

(I'm always fascinated by these little things.)

Thanks.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: dpyers
Date Posted: 11 October 2004 at 4:07pm

When you have a line like
If A=A Or B=B Or C=C Or D=D Then

There are inplied () around the equations. Most languages work from the inside out, so the equations are expanded/evaluated before the conditional operators - AND/OR's - are applied.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mart
Date Posted: 11 October 2004 at 4:25pm
I'm not certain but I think they always translate to AND conditions... i.e.

If (C = "Hello" Or C="Hi")  And (C = D) Then


The statements in parethesis will be converted to booleans so it ends up like

If True And False






Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net