Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

? local arrays retain size between function calls?

$
0
0
AutoIt         
  1. #cs ----------------------------------------------------------------------------
  2.  
  3.  AutoIt Version: 3.3.12.0
  4.  Author:         myName
  5.  
  6.  Script Function:
  7.     Template AutoIt script.
  8.  
  9. #ce ----------------------------------------------------------------------------
  10. ; ?? seems like the array is not destroyed when subroutine is exited
  11. ; Script Start - Add your code below here
  12. #include <Array.au3>
  13.  
  14.  
  15. Global $sWhereAreWe = _GetDirParent(@ScriptDir) ;; "R:\Operations\MacroTools\_RejectServiceRequestsNotInError\Programs\
  16. Global $sWhereAreWeA = _GetDirParent($sWhereAreWe) ;;"R:\Operations\MacroTools\_RejectServiceRequestsNotInError\
  17. MsgBox (0, "", $sWhereAreWe & @cr & $sWhereAreWeA  & @CR & @ScriptDir )
  18.  
  19. Func _GetDirParent ($sMyDir) ; no need for input parms, we will find where we run from
  20.  
  21. Local $text = $sMyDir ; & "\"  ;
  22. Local $array = StringSplit($text, '\', 1)
  23. MsgBox (0,"text",$text)
  24.  _ArrayDisplay($array)
  25.  
  26. Local $iUpperBound = $array[0]
  27. Local $iI
  28. Local $sParent = ""
  29.  
  30. For $iI = 1 To $iUpperBound -1
  31.     $sParent = $sParent & $array[$iI] & "\"
  32.  
  33.  MsgBox (0," ", $sParent)
  34. Return $sParent
  35.  
  36. ; Local $sS = _GetDirParent()

Attached File  arrayNotDestroyedBetweenCalls.au3.docx   83.42KB   1 downloads

 

the above code attempts to find the Parent folder of the folder provided.

It fails because the Array called array retains its upperbound between calls.

I would have thought arrays would be destroyed after the function closes and recreated with new bounds.

 

Is this an expected effect?

 
Is there anyway to force the array to be deleted and created with new bounds.
thanks
Phil

 

 

 

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>