Jump to content

Recommended Posts

Posted

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 :blink:

Posted

Please post the code that doesn't work.

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Posted

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!!

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...