mIRC Homepage
Posted By: CWO While loops not working correctly - 22/12/03 04:48 PM
OK I've come here since this while loop doesnt seem to work as its supposed to.

Code:
 
alias memorymanager {
  set %unitnumber 1
  while ( %user $+ %unitnumber != $null) {
    /inc %unitnumber 1
  }
  set %user $+ %unitnumber %username
  set %pass $+ %unitnumber %password
  set %mask $+ %unitnumber %who
}
 

Thats what the code is supposed to be. If the variable exists, move on to the next number. Here are my results of using this.

It seems when I set the while evaluation to == $null it will break out of the loop and process the set commands for %user1, %pass1, and %mask1 only whether they exist or not. (If %user1 exists its understandable but if it didnt exist, it SHOULD have ran away)

If the while evaluation is set to != $null, no matter what it runs away.

Posted By: Wiggle Re: While loops not working correctly - 22/12/03 05:16 PM
I believe this is because of the vars in your while statement. Try the following:

Code:
while (%user [ $+ [ %unitnumber ] ]) { inc %unitnumber }


%user [ $+ [ %unitnumber ] ] makes it so the %unitnumber variable gets evaluated first so you, in the end, become %user1 etc.

Tata :>
Posted By: theRat Re: While loops not working correctly - 22/12/03 06:18 PM
%unitnumber = $var(%user*,0)
© mIRC Discussion Forums