sensalim Posted October 30, 2007 Share Posted October 30, 2007 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! Link to comment Share on other sites More sharing options...
Valuater Posted October 30, 2007 Share Posted October 30, 2007 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) Link to comment Share on other sites More sharing options...
Uten Posted October 30, 2007 Share Posted October 30, 2007 Take a look at redim in the help file. Allso check out the Arrays tutorial in the wiki. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 30, 2007 Moderators Share Posted October 30, 2007 (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 October 30, 2007 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now