PDA

View Full Version : [MX] Loops! To Restart And To Break Them!



lrhb
October 13th, 2003, 07:26 PM
Hello!

I'm working on a small validation script, to check elements of a data object for duplicates... it goes a little something like this (hit it!):

for (i=0;i<_root.wddxData.getRowCount();++i){
city = _root.wddxData.ADDRESSCITY[i];
if (previousCity == city){
trace(city+" IS A DUPLICATE"); }

[...]

previousCity = city;
}

It works well enough, and goes through the recordset and tells me when there's duplicates... but what I tried didn't work. i thought if I did:

if (previousCity == city){
i = ++i; }

and continued my loop, it would work, but instead, it would catch the first duplicate, but miss the rest after that.

Basically what I'd like to do is simple: If this record[i] is equal to record[i+1], skip record[i+1] and go through it again... I just can't seem to figure it out :hat:

Advice, as always, appreciated!

ever curious,
lrhb

lrhb
October 13th, 2003, 07:33 PM
Hoah! Silly me! I figured it out...

I just reconfigured my loop to say something like:

if (previousCity != city){
do stuff;
} else {
suck a lemon;
}

Sometimes all it takes is to move stuff around! :)

lrhb