mIRC Home    About    Download    Register    News    Help

Print Thread
M
MauS
MauS
M
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.

A
as_twit
as_twit
A
var %Var $read(file.txt)

M
MauS
MauS
M
Yeah, thanks

Joined: Dec 2002
Posts: 698
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 698
var %Var = $read(file.txt)

J
j0ch3n
j0ch3n
J
Nimue, /var needs no = - /var %var bleh will work as /var %var = bleh does.

Joined: Dec 2002
Posts: 698
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 698
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.

M
MauS
MauS
M
Anyway i just needed $read(file.txt). Thanks again

K
krunch
krunch
K
Code:
$read(file.txt,$rand(0,$lines(file.txt)))


not really needed but smile

Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
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?

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
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.

J
j0ch3n
j0ch3n
J
//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,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
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.

J
j0ch3n
j0ch3n
J
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,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
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.


Link Copied to Clipboard