Subj : Learning arrays
To   : All
From : Mortifis
Date : Wed Jul 17 2019 11:09 am

So, I threw together a little script that loops through the userbase and
compares email addresses no problem, however, I am having difficulty storing
the user number in an array for access later on in the script;  what I have
tried (resulting in no list displayed.

load("sbbsdefs.js");

const REVISION = "$Revision: .01 $".split(' ')[1];

print("Synchronet Duplicate Email Address Checker " + REVISION + "\r\n");

var u; // user object
var d;
var dups=0;
var recs=0;
var dups;
var lastuser;
var has_dup = false;
var dup_u =0;

lastuser=system.lastuser;

for(i=1; i<=lastuser; i++) // loop through users and grab the email address
{
   u = new User(i);

   if(u.settings&(USER_DELETED|USER_INACTIVE))
   continue;

   // start new new loop and compare email addresses
   for(n=1; n<=lastuser; n++)
   {
       d = new User(n)
       if(u.number == d.number) continue;
       if(d.settings&(USER_DELETED|USER_INACTIVE)) continue;

       if(u.netmail == d.netmail)
       {
               print(u.alias + " [" + u.number + "] shares " + d.alias + " ["
+
d.number + "] ("+d.netmail+")\r");

               has_dup[i] = true;
               dup_u[dups] = i;
               dups++;
       }
   }

   recs++;
}

dups = dups/2; // since if one is found then 2 are found :-P

if(dups == 1) dup = "Entry"; else dup = "Entries";

for(y=1; y<= lastuser; y++) {
 if(has_dup[y] == true) {
   print("Dup user " + dup_u[y] + " user alias " + "alias "
+u.alias[dup_u[y]]);
 }
}

// ^^^^^^^^^ this section is skipped if the if(has_dup[y] == true) is commented
// out and prints undefined if used

print("\r\nScanned " + recs + " records. Found " + dups + " Duplicate " + dup +
"!\r\n\r\n");

Any help would be appreciated, Thanks






My teachers always said "You can't make a living looking out a window!", they
were wrong,  I drive truck :-P

---
� Synchronet � AlleyCat! BBS - http://alleycat.synchro.net:81