Jump to content
Sign in to follow this  
erezlevi

HELP! how can i Initialize an Array to become Empty?

Recommended Posts

erezlevi

how can I Initialize an array if it is used in serveral Gui's I was sure that GUIdelelte does it when the GUI ends, so, how can reInitilize an Array of 250 entries?

Share this post


Link to post
Share on other sites
Thatsgreat2345

What are you saying? English ? My crystal ball is broken and I just can't seem to see your code.

Share this post


Link to post
Share on other sites
GEOSoft

how can I Initialize an array if it is used in serveral Gui's I was sure that GUIdelelte does it when the GUI ends, so, how can reInitilize an Array of 250 entries?

That depends on how you built the array to begin with. If you used

Dim $arrav[x]

then you can use redim

otherwise just use

$array = ""

to empty it, then rebuild it again.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
erezlevi

That depends on how you built the array to begin with. If you used

Dim $arrav[x]

then you can use redim

otherwise just use

$array = ""

to empty it, then rebuild it again.

I did it using the:

for $i=1 to 250

_arrayinsert($MyArray,$i,"")

next

in order to Initilized it but if $array="" will work then it is much better (I have 25 Arrays.... that needs to be Initilized this way). 9000 lines of code so couldn't put it here.

Share this post


Link to post
Share on other sites
GEOSoft

I did it using the:

for $i=1 to 250

_arrayinsert($MyArray,$i,"")

next

in order to Initilized it but if $array="" will work then it is much better (I have 25 Arrays.... that needs to be Initilized this way). 9000 lines of code so couldn't put it here.

Then when you use your GUIDelete() add the line $MyArray = "" and then rebuild it with what you want.

Edit: I should have added that if you are still going to have the same number of elements (250) then you could just re-define the data for each element.

For $I = 1 To Ubound($MyArray)-1

$MyArray[$I] = <whatever you want>

Next

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
erezlevi

well, I am going to need to use the for--->Next loop I think, ReDim don't help me here it still save the values and not initilaize them, and $Array="" kills the Array definition completly.

Share this post


Link to post
Share on other sites
GEOSoft

well, I am going to need to use the for--->Next loop I think, ReDim don't help me here it still save the values and not initilaize them, and $Array="" kills the Array definition completly.

You would use $Array = "" to delete the array and then rebuild it with For/Next or whatever method you want to use. Seeing the various points where you are using $MyArray may help us some. For example if you have it declared as Global when the GUI is open but after that it is used only inside of a single function then you could als use

Func MyFunc()

Local $MyArray

<do whatever>

EndFunc

It just depends on how you are using it, but two different arrays can be used with the same name by declaring one as global and the other as local.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
erezlevi

You would use $Array = "" to delete the array and then rebuild it with For/Next or whatever method you want to use. Seeing the various points where you are using $MyArray may help us some. For example if you have it declared as Global when the GUI is open but after that it is used only inside of a single function then you could als use

Func MyFunc()

Local $MyArray

<do whatever>

EndFunc

It just depends on how you are using it, but two different arrays can be used with the same name by declaring one as global and the other as local.

you are right and gave me a great Idea! first this is how I declare my Arrays at the begining, I guess I could just redeclare it at the points when reusing them. I didn't want to create to many Arrays to do the same at varius points so I am currently using:

Dim $E[251]
Dim $U[25]
Dim $F[251]
Dim $L[251]
Dim $Q[251]
Dim $V[251]
Dim $I[251]
Dim $B[251]
Dim $C[251]
Dim $S[251]
Dim $R1[251]
Dim $R2[1]
Dim $R3[251]
Dim $R4[1]
Dim $R5[1]
$Start = 000
$start1 = 0
For $o = 1 To 250
    _ArrayInsert($E, $o, StringFormat("%03d", $Start + $o))
Next
For $o = 1 To 9
    _ArrayInsert($U, $o, StringFormat("%02d", $start1 + $o))
Next
For $o = 10 To 24
    _ArrayInsert($U, $o, $o)
Next

;_ArrayDisplay($U)

Dim $myArray

at the begining of the script. but I will do that again in varius points at the script as you suggested.Esspecialy for those I am reusing. Thank you very much.

Share this post


Link to post
Share on other sites
erezlevi

you are right and gave me a great Idea! first this is how I declare my Arrays at the begining, I guess I could just redeclare it at the points when reusing them. I didn't want to create to many Arrays to do the same at varius points so I am currently using:

Dim $E[251]
Dim $U[25]
Dim $F[251]
Dim $L[251]
Dim $Q[251]
Dim $V[251]
Dim $I[251]
Dim $B[251]
Dim $C[251]
Dim $S[251]
Dim $R1[251]
Dim $R2[1]
Dim $R3[251]
Dim $R4[1]
Dim $R5[1]
$Start = 000
$start1 = 0
For $o = 1 To 250
    _ArrayInsert($E, $o, StringFormat("%03d", $Start + $o))
Next
For $o = 1 To 9
    _ArrayInsert($U, $o, StringFormat("%02d", $start1 + $o))
Next
For $o = 10 To 24
    _ArrayInsert($U, $o, $o)
Next

;_ArrayDisplay($U)

Dim $myArray

at the begining of the script. but I will do that again in varius points at the script as you suggested.Esspecialy for those I am reusing. Thank you very much.

hi, me again, I reused them using the Local at each point and it solved the problem.

Share this post


Link to post
Share on other sites
GEOSoft

hi, me again, I reused them using the Local at each point and it solved the problem.

Glad it worked out for you.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

×