mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2003
Posts: 78
M
MauS Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: May 2003
Posts: 78
I know that /play -r Origins.txt plays a random line from file?

But how to read a line into a variable?

I need this for making random quit messages.


-= endless in a victory of a yourself =-
Joined: May 2003
Posts: 2
A
Bowl of petunias
Offline
Bowl of petunias
A
Joined: May 2003
Posts: 2
var %Var $read(file.txt)

Joined: May 2003
Posts: 78
M
MauS Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: May 2003
Posts: 78
Yeah, thanks


-= endless in a victory of a yourself =-
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
var %Var = $read(file.txt)

Joined: May 2003
Posts: 7
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: May 2003
Posts: 7
Nimue, /var needs no = - /var %var bleh will work as /var %var = bleh does.

Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Most of the time it will work without the = yes. Sometimes it will not.
It is good practice to use the correct syntax ALL the time to avoid errors when the incorrect syntax will not work.

Joined: May 2003
Posts: 78
M
MauS Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: May 2003
Posts: 78
Anyway i just needed $read(file.txt). Thanks again


-= endless in a victory of a yourself =-
Joined: Dec 2002
Posts: 94
K
Babel fish
Offline
Babel fish
K
Joined: Dec 2002
Posts: 94
Code:
$read(file.txt,$rand(0,$lines(file.txt)))


not really needed but smile


Lets get dirty
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
That rand statement is completly useless. When you don't provide the line to read from, the alias does the same exact thing. Can you say unneccisary typing?


-KingTomato
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Code:
//var %b $remove(abc,%a) | echo -s %a

Type that.

/var %var = value is the documented way, nowhere in the help file does it say that you can omit the =. There are other things that aren't mentioned in the help file and do work, but this one (omitting the =) is an abuse imo. Mainly because there are cases where it breaks.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: May 2003
Posts: 7
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: May 2003
Posts: 7
//var %b $remove(abc,%a) | echo -s %a
this doesnt work because you echo %a - but %a doesnt exist.
type //var %b $remove(abc,b) | echo -s %b
this works

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
You're missing the point. If you see more carefully, the example I mentioned does not generate an "/echo: insufficient parameters", but a "$remove(): invalid parameters": the script halts before it reaches the /echo command. Just replace "echo -s %a" with "echo -s something %a" if you're not convinced yet. Also note that your example works because it's a different case. I used a variable as a second parameter to an identifier (%a and $remove()) , you used a letter as a second parameter to the same identifier. Test stuff some more, you'll definitely get a better picture of how things (don't) work.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: May 2003
Posts: 7
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: May 2003
Posts: 7
nope, you are missing the point - the question was if the = is necessary in the /var command.
I denied that because its not. Your example has nothing to do with this topic because //var %b $remove(abc,%a) | echo -s %a of course will give an * Invalid format: $remove - this is because %a doesnt exist (so it doesnt return anything), but u use it as a substring in $remove, it's the same as if you would use $remove(abc,)
so the point is that the error is not that the = is missing in the //var command but in your $remove, if you use it properly, e.g. //var %b $remove(abc,b) it works perfect.

Last edited by j0ch3n; 08/05/03 06:01 AM.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Please don't keep it up, you're making a fool of yourself.

You want a variable that exists? Type this:
Code:
//var %b b | var %a $remove(abc,%b) | echo -s %a

Now type this:
Code:
//var %b b | var %a = $remove(abc,%b) | echo -s %a

Now read the thread again more carefully and let's hope you get it.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard