mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Dec 2002
Posts: 271
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
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) } 

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
thanks ill try that then post back
:P

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Last edited by whatsthedillio; 07/09/04 05:03 PM.
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
use: if !$lines(c.txt) {


New username: hixxy
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
:P
thankyou

Last edited by whatsthedillio; 07/09/04 05:21 PM.
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
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.


New username: hixxy
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
var %i = 1
while ($gettok(&lt;string&gt;,%i,1)) {
  if ($nick ison $gettok(&lt;string&gt;,%i,1)) { dostuff }
  inc %i
}


New username: hixxy
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
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
}


New username: hixxy
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
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

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
alias channelloop {
  var %i = 1
  while ($gettok(%chanlist,%i,58)) { 
    if ($1 ison $gettok(%chanlist,%i,58)) { return $true }
    inc %i
  }
  return $false
}


New username: hixxy
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
awesome
yea i didnt have that part
thats what i meant

thanks alot

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
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)

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
cool i never new that
thanks
:P


Link Copied to Clipboard