mIRC Home    About    Download    Register    News    Help

Print Thread
$read not being random #193971 27/01/08 07:42 PM
Joined: Dec 2007
Posts: 8
T
Trel Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Dec 2007
Posts: 8
my code is

Code:
alias quote {
  var %Line = $read("c:\mIRC Quote Files\random_quotes.txt")
  msg $active %Line
}


my text file is
1
2
3
4
5
6
7
8
9
10

However, when I do /quote
it is ALWAYS 2

Re: $read not being random [Re: Trel] #193974 27/01/08 08:01 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

Use the t switch with the $read identifier.

Originally Posted By: mirc.chm

If the first line in the file is a number, it must represent the total number of lines in the file. If you specify N = 0, mIRC returns the value of the first line if it's a number.

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.



Code:

alias quote {
  var %Line = $read("c:\mIRC Quote Files\random_quotes.txt",t)
  msg $active %Line
}



Re: $read not being random [Re: Trel] #193975 27/01/08 08:08 PM
Joined: Aug 2006
Posts: 19
R
Reaper Offline
Pikka bird
Offline
Pikka bird
R
Joined: Aug 2006
Posts: 19
it should be this

Code:
 alias quote { msg $chan $read(filename or path) } 
or 
alias quote { echo -a $read(filename or path) }


var only set the variable once so that is why you always get 2 because it is set as 2.


ReaperIRC
Killgore Computers
Re: $read not being random [Re: Reaper] #193978 27/01/08 08:26 PM
Joined: Dec 2007
Posts: 8
T
Trel Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Dec 2007
Posts: 8
Originally Posted By: Reaper
it should be this

Code:
 alias quote { msg $chan $read(filename or path) } 
or 
alias quote { echo -a $read(filename or path) }


var only set the variable once so that is why you always get 2 because it is set as 2.


If the var is the problem, is there any way to still use variables? I did plan to do more than just echo it. I just didn't make that part yet.

Re: $read not being random [Re: Reaper] #193979 27/01/08 08:28 PM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
Code:
//var %x = That's | echo -a %x | var %x = not | echo -a %x | var %x = true. | echo -a %x

Re: $read not being random [Re: Trel] #193986 27/01/08 10:03 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

The variable wasn't the problem. Did you read my reply? I left your code as it was except for the addition of the t switch in the $read identifier.

Re: $read not being random [Re: RoCk] #193992 27/01/08 11:03 PM
Joined: Dec 2007
Posts: 8
T
Trel Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Dec 2007
Posts: 8
Originally Posted By: RoCk

The variable wasn't the problem. Did you read my reply? I left your code as it was except for the addition of the t switch in the $read identifier.


Yeah, I didn't get a chance to try yet. I was asking on that one incase he was right :p
(Or if you both were right)

Re: $read not being random [Re: Trel] #194007 28/01/08 01:16 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As RoCk said, the var wasn't the issue. Just the -t switch.


Invision Support
#Invision on irc.irchighway.net
Re: $read not being random [Re: RoCk] #194019 28/01/08 09:29 AM
Joined: Dec 2007
Posts: 8
T
Trel Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Dec 2007
Posts: 8
I have it working.

(it was the -t smile )

Thanks smile