mIRC Home    About    Download    Register    News    Help

Print Thread
#133415 20/10/05 05:16 PM
Joined: Oct 2005
Posts: 2
S
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Oct 2005
Posts: 2
hello

Straight to the point...mIRC won't let me use $mid when I'm setting a /var variable.

When I change it to /set, it works fine, but I want /var not /set!

Using something like
var %text $mid($1-,%i,1)
I get
* Invalid format: $mid (line 97, sort.mrc)

Thanks in advance for advice smile

Jonny

Last edited by silverjonny; 20/10/05 05:18 PM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Tell us the exact line of code you're using so we can pinpoint the error please.
My guess is that you're not using the = sign with the /var command.

Edit:

I was right.

Code:
var %text [color:red]=[/color] $mid($1-,%i,1) 


The = IS required, despite what others might say.

Last edited by hixxy; 20/10/05 05:18 PM.
Joined: Oct 2005
Posts: 2
S
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Oct 2005
Posts: 2
Ah, thanks. I had absolutely no idea blush

cheers!

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
The reason you have this is more than likely because of /var's ability to set multiple variables in one line.

As you may or may not know, you can initialize multiple variables with one /var command like this:

//var %a = 1, %b = 2, %c = 3

The commas here are used as the delimiter between multiple variables that are to be initialized.

Let's take a look at your example:

//var %text $mid($1-,%i,1)

What happens here?

//var %text $mid($1-,%i,1)

It sees a first variable declarement for the variable %text which will get the assigned value $mid($1-
It sees a second variable declarement for the variable %i,1) which will get the assigned value $null

The reason you get an error in $mid, is simply because as you can tell, its format is incomplete, because the %i after the first comma is seen as a variable declarement. In other words, it parses the $mid incorrectly, whereas in normal conditions it would see the $mid($1-,%b,1) as a "whole".

This will apply to all identifiers which have comma's in it, where a variable is directly after this comma.

Try //var %a $rand(5,%b)
--> * Invalid format: $rand

Which is the exact same error you received in your code, cept it was with $mid.

//var %a $rand(%b,5)
--> Doesn't give an error, because the %b was before the comma, so the parser didn't mistake it for a variable declarement.

If you use the = sign, then the parser will not make this "mistake" (I don't really want to call it a mistake, because the mistake is on the users part who didn't use the correct syntax), instead it will now evaluate the entire $mid.

//var %text = $mid($1-,%b,1)


The moral of the story is: always use the correct syntax.


PS: Note that this is my assumption, the only person that is able to tell us what exactly goes wrong is Khaled.


Gone.

Link Copied to Clipboard