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.