Sometimes its necessary to compare two sets of data to find common or uncommon values. This script compares two arrays, giving the user the option to choose which comparisison to view.
'------------------------------------------------------------------ 'This page calls itself so get file name '------------------------------------------------------------------
'------------------------------------------------------------------ 'create value lists to be compared '------------------------------------------------------------------
'------------------------------------------------------------------ 'these two lines output lists for user to see during comparisons '------------------------------------------------------------------
'------------------------------------------------------------------ 'Compare arrays and find values common to both '------------------------------------------------------------------
If request("buttonchoice") = "common" then strOutput = "(" for i = 0 to ubound(ARR1) for j = 0 to ubound(ARR2) if ARR1(i)=ARR2(j) then strOutput=strOutput & ARR1(i) & "," next next
'------------------------------------------------------------------ 'Compare arrays and find values uncommon to array 1 '------------------------------------------------------------------
If request("buttonchoice") = "uncommon to 1" then strOutput = "(" for i = 0 to ubound(ARR2) found = "false" for j = 0 to ubound(ARR1) if (ARR2(i) = ARR1(j)) then found = "true" exit for end if next if found ="false" then strOutput=strOutput & ARR2(i) & "," ARR2temp = ARR2(i) end if next
'------------------------------------------------------------------ 'Compare arrays and find values uncommon to array 2 '------------------------------------------------------------------
If request("buttonchoice") = "uncommon to 2" then strOutput = "(" for i = 0 to ubound(ARR1) found = "false" for j = 0 to ubound(ARR2) if (ARR1(i) = ARR2(j)) then found = "true" exit for end if next if found ="false" then strOutput=strOutput & ARR1(i) & "," ARR1temp = ARR1(i) end if next
'------------------------------------------------------------------ 'Write output to screen, highlight in red '------------------------------------------------------------------
If Len(request("buttonchoice")) > 0 then Response.write( "<BR><FONT color='red'>" & request("buttonchoice") & " = " & strOutput & "</FONT><BR>") end if
'------------------------------------------------------------------ 'Form to collect user selection '------------------------------------------------------------------