Jump to content
Sign in to follow this  
Rofellos

Dynamic Array

Recommended Posts

In AutoIt, you can not create a dynamic array, you have to specify the length of the array when you create it. One way to create dynamic arrays is create a dynamic string, where substrings are separated by a charactere like "\", and then, use StringSplit.

$sString = ""
$sString &= "Frist String" & "\"
$sString &= "Second String" & "\"
$sString &= "Third String" & "\"

$aArray = StringSplit( $sString , "\" )

; $aArray[0] is number of substrings, in this case is 4.
; $aArray[1] is the string "Frist String"
; $aArray[2] is the string "Second String"
; $aArray[3] is the string "Third String"
; $aArray[4] is the string ""
Edited by Rofellos

Share this post


Link to post
Share on other sites

That should error because you have no delimeters in your stringsplit.


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

ReDim means that AutoIt's arrays are dynamic.

That's how i've always done it, but the OPs way is a good alternative and overly simple.

Share this post


Link to post
Share on other sites

_ArrayAdd and _ArrayPop / _ArrayDelete then :x That's the easiest way to do it properly. Constantly using StringSplit is not a good idea. You'll get confused as to whether it's a string or array you're are using and it's just as many steps (if not more) to try and edit it.

Share this post


Link to post
Share on other sites

_ArrayAdd and _ArrayPop / _ArrayDelete then :x That's the easiest way to do it properly. Constantly using StringSplit is not a good idea. You'll get confused as to whether it's a string or array you're are using and it's just as many steps (if not more) to try and edit it.

The idea was to use StringSplit() to make a function. Not constantly use StringSplit() over the source code. I didn't know _ArrayAdd, thanks.

Edited by Rofellos

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...