mIRC Homepage
this doesnt seem to be working for me,
i made an alias to return the lines in a text file
and it always says if invalid parameters
line 233
which is the $lines line
even when i type
//echo $lines(textfile.txt)
it wont work any ideas
heres the code:
-----------------------------------------------------------------------------------------------------------
on *:chat:example: {
if ($example1 == 0)
{
msg =$nick No Lines To Display
goto end
}
if ($example1 < 2)
{
msg =$nick There Is Only 1 example
var %read = $read(example.txt, 1)
tokenize 1 %read
msg =$nick Nick: $1 Address: $2 message: $3-
}
if ($example1 >= 2)
{
msg = $nick There Are $example1 lines
showallexample $nick
}
:end
}
alias example1 {
var %lines = $lines(example.txt)
return %lines
}
alias showallexample {
var %examplename = $1
var %exampletotal = $lines(example.txt)
var %examplenumber = 0
:regroup
if (%examplenumber >= %exampletotal)
{
msg =%examplename ---- example List End ----
goto end
}
inc %examplenumber 1
var %read = $read(example.txt, %examplenumber)
tokenize 1 %read
msg =%examplename line: %examplenumber Nick: $1 Address: $2 message: $3-
goto regroup
:end
}

-------------------------------------------------------------------------------------------------------------
this isnt the same as my script cuz it was hard to explain
but this is what i want
please help me
thanks alot
smile
Your getting that if error because you have the opening "{" on a different line then the if statement.. You cannot do that without error: if (condition) { commands } , The Ending "}" can be on a different line.
This is a little different then yours:

Code:
   
on *:chat:example: {
var %example = $example1
  if (%example == 0) {
    msg =$nick No Lines To Display
  }
  elseif (%example &lt; 2) {
    msg =$nick There Is Only 1 example
    var %read = $read(example.txt, 1)
    tokenize 1 %read
    msg =$nick Nick: $1 Address: $2 message: $3-
  }
  elseif (%example &gt;= 2) {
    msg = $nick There Are $example1 lines
    showallexample $nick
  }
}

alias example1 { return $lines(example.txt) } 
thanks ill try that then post back
:P
it worked with 1 line in the file
but the loop for returning each line
didnt work can anyone help me fix this
thanks alot
:P
forget that
i forgot to check through my whole script
for the if () {
thanks alot
works great now
cheers

1 thing just wondering
i have
if $lines(c.txt) == 0 {
should that be $null
or will 0 work
?
thanks
use: if !$lines(c.txt) {
:P
thankyou
i have another problem now ;D
i have this tokenised variable
and i want to count how many items are in the variable
between $chr(1)
so i use:
$addtok(%variable,$nick,1)
to set the variable
so how can i count how many
items between $chr(1)
and i need to return each nick aswell

thankyou
:P
If the tokenize string is tokenized using $chr(1) (/tokenize 1 <string>) then $0 will return the amount of parameters, otherwise $gettok(<string>,0,1) will do it.
cool thanks
but
i have a channel list in variables
so to see if the user is on 1 of the channels
i would use??
i dont understand how i can figure that out from here?
pls help
thanks alot
Code:
var %i = 1
while ($gettok(&lt;string&gt;,%i,1)) {
  if ($nick ison $gettok(&lt;string&gt;,%i,1)) { dostuff }
  inc %i
}
var %i = 1
while ($gettok(%chanlist,%i,58)) {
if ($nick ison $gettok(%chanlist,%i,58)) {
commands
}
inc %i
how can i put an else in there
or it would be better if you could show me
how i could make an alias
so i can use
if ($alaisname($nick) == $true)
because ive got to use it quite a lot in this script and its quite
tricky rearangeing the scripts

and thanks alot for the help
I'm not sure what you're asking, be more specific please.

As for adding an else:

var %i = 1
while ($gettok(%chanlist,%i,58)) {
if ($nick ison $gettok(%chanlist,%i,58)) {
commands
}
else {
commands
}
sorry,
i mean is it possible for an alias
so at first i tried:
alias channelloop {
var %i = 1
while ($gettok(%chanlist,%i,58)) {
if ($1 ison $gettok(%chanlist,%i,58)) {
return $true
}
inc %i
else { return $false }
}

so $1 in that loop bieng $nick in my script
so i type
if $channelloop($nick)
and it will do the alias with $nick
like im typing /channelloop nickname
if you understand

thanks alot
sorry if my questions are getting dumb
nvm that, i thought u would have to have some more properties to do $alias($nick)
but you dont
so thanks alot for all your help
i got it working now
:P
Code:
alias channelloop {
  var %i = 1
  while ($gettok(%chanlist,%i,58)) { 
    if ($1 ison $gettok(%chanlist,%i,58)) { return $true }
    inc %i
  }
  return $false
}
awesome
yea i didnt have that part
thats what i meant

thanks alot
Quote:
even when i type
//echo $lines(textfile.txt)
it wont work any ideas

try //echo -s $lines(textfile.txt)
or //echo -a $lines(textfile.txt)

since $lines(textfile.txt) returns a number, /echo uses this as the color and gives an error because there is no text to display (in that color)
cool i never new that
thanks
:P
© mIRC Discussion Forums