mIRC Home    About    Download    Register    News    Help

Print Thread
#75305 15/03/04 10:22 AM
Joined: Dec 2002
Posts: 8
S
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Dec 2002
Posts: 8
Well long time no post here heh, been here since 2002 yikes laugh anyways... back on subject... I have this alias :
Code:
alias calclvl {
  var %i = 0, %b = 1, %a = $lines(Levels\ $+ % [ $+ [ $1 ] ])
  while (%i <= %a) {
    .set %TMP_LVL $calc($read(Levels\ $+ % [ $+ [ $1 ] ], %i) + $read(Levels\ $+ % [ $+ [ $1 ] ], %b))
    inc %i
    inc %b
  }
}


Now whats it doing is $1 = a name like Bob or what not it reads C:\Levels\Bob and within bob it has:
-
10
10
-
So a total of two lines right what i want it to do is read all the lines in what ever i tell it to read like bob or mike or josh etc something to do with the filename is what $1 is but its set as a %... now all i want it to do is add 10 and 10 together and make %TMP_LVL equal to 20 ... and lets say it had 10 on each line for 3 lines i want it to add all three lines and make %TMP_LVL equal to 30 and so on... But what im getting so far is that its setting %TMP_LVL to 0 which i do know why but i can resolve any help would be nice blush)

#75306 15/03/04 05:22 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
From the help file:
  • If the first line in the file is a number , it must represent the total number of lines in the file.
    ...
    If the t switch is specified then mIRC will treat the first line in the file as plain text, even if it is a number.
Try to use $read(file,t,%i) in your script, or take this version instead:
  • alias calclvl {
    var %file = Levels\ $+ $$1
    bread %file 0 $file(%file).size &var
    set %TMP_LVL $calc($replace($bvar(&var,1-).text,$crlf,+))
    }
(Note: due to mIRC limitations, this script will break ("line too long") if your file size is greater than ~950 bytes. Don't use it if you expect such sizes)


Link Copied to Clipboard