edgariyu Posted July 6, 2010 Posted July 6, 2010 Hi everyone! I've a doubt (think it's a bit rookie) but i'm in fact rookie with Autoit My doubt is that i'm trying to use StringTrimLeft with a variable that contains a string and doesn't work. If you use the function with the string "+something+something", and you want to trim the first character there's no problem, but if you use a var like $foo = "+something+something" and then you want to trim it like StringTrimLeft($foo,1) there's no trim after using the function. I would like to know if there's any way to do that (abviously i'm using a var because the value i'm expecting changes every spin of the loop). Thanks in advance
somdcomputerguy Posted July 6, 2010 Posted July 6, 2010 (edited) This works OK for me $foo = "+something+something" MsgBox(4096, "", $foo & @LF & @LF & StringTrimLeft($foo,1)) Edited July 6, 2010 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
ajag Posted July 6, 2010 Posted July 6, 2010 Please post the code that doesn't work. Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
edgariyu Posted July 6, 2010 Author Posted July 6, 2010 It's part of a big code, but the values of $KW comes from a ExcelReadCell of an Excel sheet and are of the tipe foo,fooo The trim is inside the first conditional, after the For bucle. For $j=1 To UBound($KW) Step +1 For $i=2 To UBound($KW) Step +1 If $KW[$i][$j] <> "*" Then $split=StringSplit($KW[$i][$j],",") $query="" For $z=1 To $split[0] Step +1 ConsoleWrite($split[$z] & @CRLF) $query = $query & "+" & $split[$z] Next StringTrimLeft($query,1) $queries[$count] = $query ConsoleWrite ("any changes?: " & $queries[$count]) $count+=1 Else ; no hay mas KW en esta temática If ($KW[$i][$j] = "*") Then ExitLoop EndIf EndIf Next If ($KW[1][$j+1] = "*") Then ExitLoop EndIf Next I don't know why your example works, but when i try with my code doesn't work :s Thanks for your help!!
somdcomputerguy Posted July 6, 2010 Posted July 6, 2010 I suspect it is working correctly, but you are not displaying the return value of StringTrimLeft.Change StringTrimLeft($query,1)to ConsoleWrite(StringTrimLeft($query,1) & @LF)and it should work as expected. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
ajag Posted July 6, 2010 Posted July 6, 2010 So you should write $query = StringTrimLeft($query,1) A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
somdcomputerguy Posted July 6, 2010 Posted July 6, 2010 I was just thinking that too.. Instead of ConsoleWriting it out. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now