Page 1 of 1

Compare Variable Sets: each in set 1 against each in set 2?

Posted: Fri Jun 13, 2008 1:04 pm
by JAB Creations
I'm trying to simulate a long repetitive comparison of 26 variables against 26 other variables.

If everything was spit out as plain text it (and the range were reduced to 0~2) would look something like...
ii00 =?= ce00
ii10 =?= ce00
ii20 =?= ce00
ii00 =?= ce10
ii10 =?= ce10
ii20 =?= ce10
ii00 =?= ce20
ii10 =?= ce20
ii20 =?= ce20

However the code below currently alerts as so (reduced to 2 from 26 to make it a little less obnoxious for testing purposes)...
ii00 =?= ce00
ii10 =?= ce10
ii20 =?= ce20
ii30 =?= ce30
ii40 =?= ce40
ii50 =?= ce50

The main issue to take in to consideration is that the numerical position is relative, not absolute. That means the variable ii00 might match ce40. So every ii variable must be compared against every ce variable. Of course I can return once a match is found.

Also keep in mind that the ending 0 in each variable marks it as containing a type of string variable (it's intentionally there and while it should be included it should be ignored).

However I'm feeling a bit clueless of how to execute this. Keep in mind I only want to alert this stuff right now so I can visually ensure everything is cross comparing as desired.

Here is my current script...

Code: Select all

function fill_values(){ for (var i=0; i<2; i++) //26 { var the_selector = i; alert('ii' + the_selector + '0 =?= ' + 'ce' + i+ + '0'); }}

Re: Compare Variable Sets: each in set 1 against each in set 2?

Posted: Fri Jun 13, 2008 2:00 pm
by JAB Creations
Haha I don't know why I didn't think of this before!

Check it out...easy enough to manipulate the ranges too! :mrgreen:

Code: Select all

function fill_values(my_param){ for (var i=0; i<6; i++) //26 { var the_selector = i; alert('ii' + the_selector + '0 =?= ' + 'ce' + my_param + '0'); }} function fill_values_exec(){ for (var i=0; i<3; i++) //26 {  fill_values(i++); }}

Re: Compare Variable Sets: each in set 1 against each in set 2?

Posted: Sat Jun 14, 2008 7:22 pm
by JellyFish
Why are you using multiple variables when you could use arrays?

Code: Select all

 
ii[10] == ce[10]
 

Re: Compare Variable Sets: each in set 1 against each in set 2?

Posted: Sun Jun 15, 2008 5:42 am
by JAB Creations
This is merely a visual test script for me to confirm whether what I was trying to achieve was working or not.