Sign in to follow this  
Followers 0
Valuater

$result = StringTrimLeft("I am a string", 3)

3 posts in this topic

Just a little clearification

Are'nt these the same ?????

$result = StringTrimLeft($myArray, 3)

$result = _ArrayTrim( $myArray, 3)

or is there a more specific use

thx 8)


NEWHeader1.png

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Depends on what is in $myArray.

#include <Array.au3>
Dim $myarray[2]
$myarray[0] = 'Hello world'
$myarray[1] = 'Ola senior!'

msgbox(0,'Default', $myarray[0] & @LF & $myarray[1])

StringTrimLeft($myarray, 3)

msgbox(0,'StringTrimLeft', $myarray[0] & @LF & $myarray[1])

_ArrayTrim($myarray, 3)

msgbox(0,'_ArrayTrim', $myarray[0] & @LF & $myarray[1])

Note that StringTrimLeft, didn't do anything, because a) It doesn't work on arrays, and :( It doesn't affect the variable by reference, it returns the changed string.

In fact, if you do this:

Dim $myarray[2]
$myarray[0] = 'Hello world'
$myarray[1] = 'Ola senior!'

$myarray = StringTrimLeft($myarray, 3)
msgbox(0,'Default', $myarray[0] & @LF & $myarray[1])

You get an error because $myarray is no longer an array.

I can't actually see how you assumed that either of them do the same thing at all. Did you even try them first?

Edited by Saunders

Share this post


Link to post
Share on other sites

no, i didn't try them first.. this is new ground for me and i did not know how to test it to this degree

You gave an absolutely perfect example............ thank you

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0