Jump to content

Dimmension array by Variable


Recommended Posts

  • Developers

Ok...so I don't really understand why AutoIt will does not support or will not let me dimmension an array by a variable...

CODE

$MyIntegerVariable

Dim $MyArray[$MyIntegerVariable]

any ideas of why it isnt working or a substitute?
You can dim an array with a variable.. the posted code isn't valid code, so post a scriptlet that shows the problem to allow us to help you...

:P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

CODE
func xAddToList($xPath, $xData, $xListViewCTRL)

$xFilesContainer=FileOpen($xPath,1) ;Open the log

FileWriteLine($xPath, $xData) ;Add the entry

Fileclose($xFilesContainer) ;Close the log

Global $xRunTimeCTRLs ;Keep Global records of ammount of RunTime added ListViewItems

Global $xRunTimeCTRLID[$xRunTimeCTRLs]

_ArrayAdd($xRunTimeCTRLID, GUICtrlCreateListViewItem($xData, $xListViewCTRL))

$xRunTimeCTRLs=$xRunTimeCTRLs+1

EndFunc

I am fairly sure looking at it now that not specifying a value to the $RunTimeCTRLs caused the error...

I therefore ask a new question... This function will be run multiple times and the array $xRunTimeCTRLID[] must keep a record of all of the control IDs... $xRunTimeCTRLs keeps a record of how many times the function has been ran and therefore how many elements the array must have... How can I redimmension the array several times increasing it by one each time it is ran... *Sorry if newbish 3rd day using AutoIt3*

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Link to comment
Share on other sites

  • Developers

Something like this ?

(don't need to do a fileopen/fileclose when you write the to filename ....)

;start of the script
Global $xRunTimeCTRLID[1]
Global $xRunTimeCTRLs           ;Keep Global records of ammount of RunTime added ListViewItems

;
;
Func xAddToList($xPath, $xData, $xListViewCTRL)
    FileWriteLine($xPath, $xData) ;Add the entry
    Redim $xRunTimeCTRLID[$xRunTimeCTRLs]
    _ArrayAdd($xRunTimeCTRLID, GUICtrlCreateListViewItem($xData, $xListViewCTRL))
    $xRunTimeCTRLs = $xRunTimeCTRLs + 1
EndFunc   ;==>xAddToList

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thank you very much, The biggest problem was the location of the counter being after the redim of the array so I was trying to set the array elements to 0 which is not possible :-/ ... Here is my debugged code..

CODE
func xAddToList($xPath, $xData, $xListViewCTRL)

FileWriteLine($xPath, $xData) ;Add the entry

Global $xRunTimeCTRLs ;Keep Global records of ammount of RunTime added ListViewItems

$xRunTimeCTRLs=$xRunTimeCTRLs+1

Select

case $xRunTimeCTRLs=1

Global $xRunTimeCTRLID[$xRunTimeCTRLs]

case $xRunTimeCTRLs>1

ReDim $xRunTimeCTRLID[$xRunTimeCTRLs]

EndSelect

_ArrayAdd($xRunTimeCTRLID, GUICtrlCreateListViewItem($xData, $xListViewCTRL))

_ArrayDisplay($xRunTimeCTRLID,"")

msgbox(0,"",$xRunTimeCTRLs)

EndFunc

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...