Sign in to follow this  
Followers 0
sensalim

Clouded on Array

4 posts in this topic

What is the proper way of creating a dynamic array (I mean array that is flexible, that I don't have to tell how big it is when declaring)?

Thanks!

Share this post


Link to post
Share on other sites



here, $aRecords is declared locally, however the size is given from the amount of files found

#include<guiconstants.au3>
#include <file.au3>

$file = "C:\test.txt"
$width = 100
$info = ""
$aRecords = ""

If Not _FileReadToArray($file,$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aRecords[0]
    If (StringLen($aRecords[$x]) * 5.5) > $width Then $width = (StringLen($aRecords[$x]) * 5.5)
    $info = $info & $aRecords[$x] & "|"
Next
$info = StringTrimRight($info, 1)

GUICreate("My GUI", $width + 20, 100)
$Combo = GUICtrlCreateCombo("", 10, 10, $width)
GUICtrlSetData($Combo, $info)
GUISetState()

While GUIGetMsg() <> -3
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What is the proper way of creating a dynamic array (I mean array that is flexible, that I don't have to tell how big it is when declaring)?

Thanks!

As others have pointed out... ReDim - but be smart how you do it... ReDim in a loop constantly is just too much work and takes a toll on speed.

GLOBAL $aVar[1]

ReDim $aVar[3]

$aVar[1] = "A"
MsgBox(64, "Info", $aVar[1])
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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