Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Return an Array that contains only the diffrent items from 2 arrays

Reply
Thread Tools

Return an Array that contains only the diffrent items from 2 arrays

 
 
Erv
Guest
Posts: n/a
 
      04-26-2007
<%
' Return item that are NOT duplicated in either array
function ShowDiff(array1, array2)
dim d, item, thekeys, build_arr

' Build Array - a command that will be Execute
build_arr = "anArray = ARRAY("

' Loop through the first array, add to output
for x = lbound(array1) to ubound(array1)
build_arr = build_arr & "array1(" & x & "), "
next

' Loop through the second array, add to output
for y = lbound(array2) to ubound(array2)
build_arr = build_arr & "array2(" & y & "), "
next

' Cleanup last comma
build_arr = left(build_arr, len(build_arr) - 2)
build_arr = build_arr & " )"

' Excute the build statement
execute build_arr


' Show differences
set d = CreateObject("Scripting.Dictionary")
d.removeall
d.CompareMode = 0
for each item in anArray
if not d.Exists(item) then
d.Add item, item
else
d.Remove item
end if
next
thekeys = d.keys
set d = nothing
ShowDiff = thekeys
end function
%>

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-26-2007
Erv wrote:
> <%
> ' Return item that are NOT duplicated in either array
> function ShowDiff(array1, array2)
> dim d, item, thekeys, build_arr
>
> ' Build Array - a command that will be Execute
> build_arr = "anArray = ARRAY("


You expect us to embrace a script that uses Execute to execute a
string???
Give it some thought. I'm sure you can come up with a way to avoid
Execute.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
Two arrays: return only values that exist in both arrays? Joshua Muheim Ruby 8 11-23-2007 07:04 PM
etherchannel with diffrent speeds, how to trick it? Colin Cant Cisco 3 01-31-2005 07:18 PM
Regex problem, match if line contains <a>, unless it also contains <b> James Dyer Perl 5 02-20-2004 12:29 PM



Advertisments