aiter Posted July 27, 2016 Posted July 27, 2016 I have an array $aArr[50][10] I have a loop that builds the values within this array At the beginning of the loop, I want to clear out this array but keep its dimensions Do I need to loop through all the rows and the columns and assign null to each cell or is there an easier way global $aArr[50][10] While flag $aArr = '' ;<---- I think this will clear it, but how do I specify its an array again ; code below this will fill $aArr wend
TheDcoder Posted July 27, 2016 Posted July 27, 2016 Redeclare the Array... Something like this: #include <Array.au3> Global $aArray[3] = [1, 2, 3] ; Create the array for the first time _ArrayDisplay($aArray) ; Display the array Global $aArray[3] ; Redeclare the array _ArrayDisplay($aArray) ; Display the array again ; P.S Try running this script to see what I mean. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
aiter Posted July 27, 2016 Author Posted July 27, 2016 I see thanks. Is there way to blanket initialize an array to a value? eg global $aArr[10][10] = '1' ; assign 1 to every cell
TheDcoder Posted July 27, 2016 Posted July 27, 2016 Just now, aiter said: Is there way to blanket initialize an array to a value? Not that I know of, You need to a custom code a loop for that... EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
Moderators JLogan3o13 Posted July 27, 2016 Moderators Posted July 27, 2016 Something like this to fill it? #include <Array.au3> Local $aArray[10][10] _ArrayDisplay($aArray) For $a = 0 To 9 For $b = 0 To 9 $aArray[$a][$b] = 1 Next Next _ArrayDisplay($aArray) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
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