mIRC Home    About    Download    Register    News    Help

Print Thread
While loops not working correctly #64868 22/12/03 04:48 PM
Joined: Oct 2003
Posts: 9
C
CWO Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Oct 2003
Posts: 9
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.


Re: While loops not working correctly #64869 22/12/03 05:16 PM
Joined: Dec 2002
Posts: 14
W
Wiggle Offline
Pikka bird
Offline
Pikka bird
W
Joined: Dec 2002
Posts: 14
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 :>

Re: While loops not working correctly #64870 22/12/03 06:18 PM
Joined: Dec 2002
Posts: 774
T
theRat Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
%unitnumber = $var(%user*,0)


Code:
//if ( khaled isgod ) echo yes | else echo no