Sign in to follow this  
Followers 0
Deon

Duplicate column in array and stringleft the value

4 posts in this topic

I have an array that looks like:

______________________
|123456|ABCDEF|999999|
______________________

And I want to have Autoit create a new column at the start and grab the first 3 characters of the next column, so the array would now look like this:

__________________________
123|123456|ABCDEF|999999|
__________________________

I've had a bit of a play with some of the _Array functions but can't really find anything to duplicate the column, so I'm not sure where to start.

 

Any help appreciated!

Share this post


Link to post
Share on other sites



#include <Array.au3>

Local $array1[1][3] = [[123456,"ABCDEF",999999]]
Local $array2[UBound($array1)][UBound($array1, 2) + 1]

For $i = 0 To UBound($array1) -1
    $array2[$i][0] = StringLeft($array1[$i][0], 3)
    $array2[$i][1] = $array1[$i][0]
    $array2[$i][2] = $array1[$i][1]
    $array2[$i][3] = $array1[$i][2]
Next

_ArrayDisplay($array2)

 

1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <Array.au3>

Local $a[2][3] = [[123456,"ABCDEF",999999],["blah","ablah","bblah"]]
ReDim $a[UBound($a)][4]

For $i = 0 To UBound($a)-1
    $a[$i][3] = $a[$i][2]
    $a[$i][2] = $a[$i][1]
    $a[$i][1] = $a[$i][0]
    $a[$i][0] = StringLeft($a[$i][0],3)
Next

_ArrayDisplay($a)

edit: beat me by this much *fingers very close together*

Edited by jdelaney
1 person likes this

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks gents, works perfectly.

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