| | 
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,030 Hoopy frood |  
| OP   Hoopy frood Joined:  Jul 2006 Posts: 4,030 | 
In first, with this ://var %t = GA is Ga ,%b = $len(%t) ,%a 1 | while (%a <= %b) { var -s %r = $+(%r,$mid(%t,%a,1)) | inc %a }
 
 all the spaces of %t will be removed in %r, why ? is it a bug ?
 
 Other thing, : why can't we set a %var ( with /var ) if the var name doesn't begin with a % like :
 //Var -s $+(%,a,b) 1
 is it a bug too ?
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  Aug 2004 Posts: 7,168 Hoopy frood |  
|   Hoopy frood Joined:  Aug 2004 Posts: 7,168 | 
The stripping of multiple spaces is not a bug, but intentional.  There have been many posts regarding multiple spaces.  mIRC also does not allow leading or following spaces.  There are ways around this, most notably, using a 3rd party dll called spaces.dll mIRC recognizes two characters for variable names, depending on the type of variable that you're wanting/needing to work with. The most common one is the local/global variable (local variables are set using /var, global variables are set using /set).  If the % character isn't present, then mIRC doesn't know that it's a variable. I find it interesting that I can use   and it works properly, yet your example does not. Note: If, for some reason, you must use a local variable, you can set it using the /set command and the -l switch.  This method does work as a workaround for the second bug you posted. |  |  |  
| 
| 
|  |  
| 
Om3n
 |  
| Om3n | 
1. Your problem is "var -s %r = $+(%r,$mid(%t,%a,1))", when it reaches a space in the string, $mid will evalutate to a space and your command will become "var -s %r = $+(%r, )".  Obviously you cant $+ a space...
 2. Not sure why "var -s $+(%,a,b) 1" does not work, as it works fine when using set -s (note: square braces around it dont help)
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jan 2003 Posts: 2,125 Hoopy frood |  
|   Hoopy frood Joined:  Jan 2003 Posts: 2,125 | 
1. Your problem is "var -s %r = $+(%r,$mid(%t,%a,1))", when it reaches a space in the string, $mid will evalutate to a space and your command will become "var -s %r = $+(%r, )". Obviously you cant $+ a space...That's not it at all, try "var -s %r = $+(%r,$mid(%t,%a,1),anythinghere)" for example, you'll find it works if $mid() returns a space. /var and /set can handle any number of consecutive or leading spaces; there only is a problem with a single trailing space . All mirc identifiers (including custom ones, if one uses the undocumented but apparently quite stable /returnex command) can also handle consecutive/leading/trailing spaces fine. Only /commands  (other than /var and /set) strip leading/trailing spaces and reduce consecutive spaces to a single one. The interested reader can find lots more about the whole spaces issue in this comprehensive mIRC Internals Wiki article . Examples: //var %a = $str($chr(32),3) $+ a | echo -a $len(%a) echoes "4". 3 consecutive leading spaces, followed by "a", were successfully stored in %a. //var %a = $str($chr(32),3) | echo -a $len(%a) echoes "3". 3 consecutive spaces where successfully stored in %a. Since nothing else follows, those are also trailing spaces . //var %a = a $+ $str($chr(32),3) | echo -a $len(%a) echoes "4". Similar to above. //var %a = a $+ $str($chr(32),1 ) | echo -a $len(%a) echoes "1". The space was lost in this case, because it was the last character and  the character before that was not  a space. |  |  |  
| 
| 
|  |  
| 
Om3n
 |  
| Om3n | 
Perhapse my wording was not specific enough, you cant $+ LITERAL spaces. Using $str and $chr is a workaround, the point was that the problem with the OP's code is that $mid evaluates to a literal space, which is infact why it is not functioning as they expected.
 I am well aware of the spaces issue, and that no single trailing space (in any form) can be used in that way.  Although i am sure the OP will appreciate your explanation since i failed to do so myself.
 
 To OP: you would need to check for this case, eg..
 //var %t = GA is Ga, %b = $len(%t), %a 1 | while (%a <= %b) { if ( $mid(%t,%a,1) == $chr(32) ) { var -s %r = $+(%r,$mid(%t,%a,2)) | inc %a 2 } | else { var -s %r = $+(%r,$mid(%t,%a,1)) | inc %a } }
 
Last edited by Om3n; 10/04/07 02:22 PM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2004 Posts: 701 Hoopy frood |  
|   Hoopy frood Joined:  Apr 2004 Posts: 701 | 
the point was that the problem with the OP's code is that $mid evaluates to a literal space, which is infact why it is not functioning as they expected.If that is the case, then why does the following code work just fine? //var %t = GA is Ga ,%b = $len(%t) ,%a 1 | while (%b >= %a) { var -s %r = $+($mid(%t,%b,1),%r) | dec %b } 
 Saturn, QuakeNet staff
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,030 Hoopy frood |  
| OP   Hoopy frood Joined:  Jul 2006 Posts: 4,030 | 
Thanks for explanation but i supposed it was something like that (and so it was not a bug).I don't need any workaround, it was just exemple to show the problem.
 But for the second problem, i know i can use set -l but the bug is here for me : we can't use /Var $+(%,a,b) 1 whereas we can use /set -l $+(%,a,b) 1
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  Dec 2002 Posts: 2,002 Hoopy frood |  
|   Hoopy frood Joined:  Dec 2002 Posts: 2,002 | 
I'm going to call the 2nd one a bug because nomatter what I tried, I couldn't get it to work.
 |  |  |  
| 
| 
|  |  
| 
Om3n
 |  
| Om3n | 
Sigh... concidering the OP's post, and the subsequent replies, i think it was established that we were talking about trailing spaces not leading spaces.  I was replying to, and inreference of, the OP's specific example. |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2004 Posts: 701 Hoopy frood |  
|   Hoopy frood Joined:  Apr 2004 Posts: 701 | 
Hmm, I thought you were talking about "literal" vs "non-literal" spaces, and the ability to concatenate those, in general (instead of in the very specific /var single-trailing-space-bug context). If that's not what you meant, then I have nothing to say.   
 Saturn, QuakeNet staff
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,030 Hoopy frood |  
| OP   Hoopy frood Joined:  Jul 2006 Posts: 4,030 | 
Just find another strange thing with /var :
 //var % 1 | echo -a %a \ $var(%).value
 
 and after :
 
 //set % 56 | var % 1  | echo 4 -a $var(%).value | unset % | echo 6 -a $var(%).value
 
 this would echos :
 2
 1
 
 and i don't know why .
 
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  Aug 2004 Posts: 7,168 Hoopy frood |  
|   Hoopy frood Joined:  Aug 2004 Posts: 7,168 | 
Try using the correct format for a variable name, specifically something along the lines of %a not %
 |  |  |  
| 
| 
|  |  
| 
Joined:  Mar 2006 Posts: 392 Pan-dimensional mouse |  
|   Pan-dimensional mouse Joined:  Mar 2006 Posts: 392 | 
I dont get why some things can't be /var'd but can be /set'd
 
 I think i had the problem with using things like $left & $right
 
 [02:16] * Titanic has quit IRC (Excess Flood)
 |  |  |  
| 
| 
|  |  
| 
Joined:  Aug 2004 Posts: 7,168 Hoopy frood |  
|   Hoopy frood Joined:  Aug 2004 Posts: 7,168 | 
The set command creates a global variable.  The var command creates a local variable.  Local variables can also be created using the -l switch in the set command.Local variables only stay for a period of time -- usually until the script ends -- however, I have come across times when a local variable has been unset before the script ended, especially when it's been a big script (ie: 25k+)
 
 Global variables don't get unset until you unset them (or reset them).
 
 None of this counteracts my earlier statement about using proper variable names.
 
 |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2003 Posts: 806 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2003 Posts: 806 | 
Just find another strange thing with /var :
 //var % 1 | echo -a %a \ $var(%).value
 
 and after :
 
 //set % 56 | var % 1  | echo 4 -a $var(%).value | unset % | echo 6 -a $var(%).value
 
 this would echos :
 2
 1
 
 and i don't know why .
 
Firstly, you should use the correct $var usage ($var(%var,N).value ): //set % set | var % var  | echo 4 -a $var(%,1).value | unset % | echo 6 -a $var(%,1).valueThis will echo... ...and it shouldn't. It should be "var" and "set". Although /var is lacking the '=' sign in your code, I've found the issue isn't due to that, but rather to a variable name weirdness, like RusselB suggested. Anything other than '%' will work: //set %% set | var %% var  | echo 4 -a $var(%%,1).value | unset %% | echo 6 -a $var(%%,1).valueNevertheless, you should include the '=' sign in your /var commands, as the practice of not doing it has been proven unsafe by many times in these forums. |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,030 Hoopy frood |  
| OP   Hoopy frood Joined:  Jul 2006 Posts: 4,030 | 
Why do you thing i post here, because i'd rather that /Var or /set % 1 will return an error since we don't specify a valid entry for the variable name
 For the "=" of /var % 1 and the format of $var, watch this :
 
 //var % = 1 | echo 4 -a $var(%,1).value
 
 As i said, i think /Var or /set with '%' should return an error
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  Aug 2004 Posts: 7,168 Hoopy frood |  
|   Hoopy frood Joined:  Aug 2004 Posts: 7,168 | 
OK...In that case I agree completely, since using % without anything else would be an incorrect variable name.  I'm not sure if I missed that point earlier, or if I just misunderstood what you were saying.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,030 Hoopy frood |  
| OP   Hoopy frood Joined:  Jul 2006 Posts: 4,030 | 
But i would have liked some explanation about the result of $varbecause /var % 1 | echo -a $var(%) $var(%).value will echos 1 1 and
 and //set -u1 % 1 | //var % 1 | echo -a $var(%) $var(%).value echos 2 2
 
 for the "=" and $var, in fact i made a mistake, i forgot some exemple :
 
 //var % = 1 | echo 4 -a $var(%,1).value > = 1
 //var % = 1 | echo 4 -a $var(%).value > 1
 //set -su1 % 2 | var -s % = 2 | echo -a $var(%) $var(%).value > 2 2
 //var -s % = 2 | echo -a $var(%) $var(%).value > 1 1
 
 we can see % is egual to = 2
 
 
 
 
 
 
Last edited by Wims; 15/04/07 06:05 PM.
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  | 
 |