Sign in to follow this  
Followers 0
Psibernetic

Dimmension array by Variable

5 posts in this topic

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?


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

Share this post


Link to post
Share on other sites



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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

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