Ahh the good ole days

Post Reply
User avatar
jessica
Site Admin
Posts: 31
Joined: Thu Sep 06, 2018 3:17 pm
Location: Cincinnati, Ohio
Contact:

Ahh the good ole days

Post by jessica » Tue Sep 18, 2018 11:20 am

I was asked to re-vamp an old PAR system at work and they wanted to do as minimum as possible to make the thing work like it should. I was told to just leave it as the old classic ASP code and add the functionality they wanted. Needless to say this actually took longer then just rebuilding the entire system to something a little more current.

I wanted to share some of the hair pulling I found along my journey, here is a great example of how classic ASP does not have short circuit evaluation on their 'if statements'.




<%
dim var1, var2, var3, var4, var5, var6

var1 = true
var2 = false
var3 = "1"
var4 = "0"
var5 = "First Name"
var6 = "Last Name"
'var7 is not to be Assigned

if var1 then
response.write("Var1 is recoginized as true<br />" & vbCrLf)
else
response.write("Var1 is not recoginized as true<br />" & vbCrLf)
end if
' OUTPUT: Var1 is recoginized as true

if not var2 then
response.write("Var2 is recoginized as NOT<br />" & vbCrLf)
elseif var2 = false then
response.write("Var2 is recoginized as false<br />" & vbCrLf)
else
response.write("Var2 is not recoginized as false<br />" & vbCrLf)
end if
' OUTPUT: Var2 is recoginized as NOT

if var1 and var2 then
response.write("Var1 and Var2 did not match correctly<br />" & vbCrLf)
elseif var1 and var2 = false then
response.write("Var1 and Var2 matched correctly<br />" & vbCrLf)
else
response.write("What a weird world we live in with Var1 and Var2<br />" & vbCrLf)
end if
' OUTPUT: Var1 and Var2 matched correctly

if var5 = "" then
response.write("Var5 shows it existed, but doesn't matter what<br />" & vbCrLf)
else
response.write("Var5 does exist, but it didn't match.<br />" & vbCrLf)
end if
' OUTPUT: Var5 does exist, but it didn't match

if (var1) and (var5 = "First Name") or (not var2) and (var6 = "Name Last") then
response.write("Welcome to Classic ASP<br />" & vbCrLf)
else
response.write("Var6 should fail<br />" & vbCrLf)
end if
'OUTPUT: Welcome to Classic ASP

if var5 then
response.write("Var5 shows it existed, but doesn't matter what<br />" & vbCrLf)
else
response.write("Var5 does exist, but it didn't match.<br />" & vbCrLf)
end if
'OUTPUT:
'Microsoft VBScript runtime error '800a000d'
'Type mismatch: '[string: "First Name"]'
'/_PARSYSTEM/assets/playarea.asp, line 44
%>
Post Reply