Sign in to follow this  
Followers 0
3nc5y9710n256b1t

Hi

9 posts in this topic

Hi I'm new to autoit.

Where should I start?

Share this post


Link to post
Share on other sites



I dont want to make another thead in this short timeframe becuase I think that would be spam and i cant edit my original post :) so i'm asking my question here.

is there something like stringsplit("1234","") that would give me thia array?

$aArray[0] = 2

$aArray[1] = "12"

$aArray[2] = "34"

?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I haven't looked for a function, but I made this... :)

#include <Array.au3>

$string = "1234567890"

$array = _StringSplitBy($string, 2)

_ArrayDisplay($array)

Func _StringSplitBy($string, $count)
    $c = 1
    $split = StringSplit($string, "")
    Local $rArray[UBound($split)]
    ConsoleWrite(UBound($split) & @CRLF)
    For $i = 1 To UBound($split) - 1 Step $count
        ConsoleWrite("I = " & $i & @CRLF)
        For $x = $i To $i + $count -1
            ConsoleWrite("X = " & $x & @CRLF)
            $rArray[$c] &= $split[$x]
        Next
        $c += 1
    Next
    ReDim $rArray[$c]
    $rArray[0] = $c - 1
    Return $rArray
EndFunc ;==>_StringSplitBy

Also, check out my tutorial. The link is in my sig.

Cheers,

Brett

Edited by BrettF

Share this post


Link to post
Share on other sites

I dont want to make another thead in this short timeframe becuase I think that would be spam and i cant edit my original post :) so i'm asking my question here.

is there something like stringsplit("1234","") that would give me thia array?

$aArray[0] = 2

$aArray[1] = "12"

$aArray[2] = "34"

?

You could try using StringLeft and then stringTrimLeft (or right for both)... Short example to get you started

$num = "1234"
$first = StringLeft($num, 1)
$num = StringTrimLeft($num, 1)
$secondTwo = StringLeft($num, 2)
...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

You could try using StringLeft and then stringTrimLeft (or right for both)... Short example to get you started

$num = "1234"
$first = StringLeft($num, 1)
$num = StringTrimLeft($num, 1)
$secondTwo = StringLeft($num, 2)
...
Awesome. New method using StringMid()

#include <Array.au3>

$string = "1234567890"

$array = _StringSplitBy($string, 2)

_ArrayDisplay($array)

Func _StringSplitBy($string, $count)
    Local $rArray[StringLen ($string)]
    Local $x = 1
    For $i = 1 To StringLen ($string) Step $count
        $rArray[$x] = StringMid ($string, $i, $count)
        $x += 1
    Next
    ReDim $rArray[$x]
    $rArray[0] = $x - 1
    Return $rArray
EndFunc  ;==>_StringSplitBy

Share this post


Link to post
Share on other sites

Another quick and dirty version from me :-)

#include <array.au3>

$string = "1234"
$aArray = MyStringSplit($string)
_ArrayDisplay($aArray)

Func MyStringSplit($string)
    Local $len = StringLen($string) / 2
    Local $aArray[$len + 1]
    $aArray[0] = $len
    
    For $i = 1 To $len
        $aArray[$i] = StringMid($string, $i*2-1, 2)
    Next
    
    Return $aArray
EndFunc

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