Jump to content

Array within a Loop


Recommended Posts

For $i = 0 To UBound($Array1) - 1
Global $ArrayInQuestion = StringRegExp($Array1[$i],'whatever',3)
SomeFunction($ArrayInQuestion)
Next

For the code above, will $ArrayInQuestion's value be set each loop cycle independent of what it already is? Or will I run into carry-over issues from the previous loop?

For example...

First Cycle:

  • StringRegExp returns elements 0-10 as matches.
Second Cycle:
  • StringRegExp returns elements 0-5 as matches.
Will $ArrayInQuestion still contain elements 6-10 from the first cycle?
Link to comment
Share on other sites

1st it is not a good idea to declare variables in a loop and 2nd the variable (array) $ArrayInQuestion will be overwritten per cycle.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

if you need to store all the array's from the prior runs, you need to declare a second array to house them all...as written, all prior loops will be overwritten

Dim $aaHousingArray[1]
For $i = 0 To UBound($Array1) - 1
$aaHousingArray[ubound($aaHousingArray)-1] = StringRegExp($Array1[$i],'whatever',3)
SomeFunction($aaHousingArray[ubound($aaHousingArray)-1])

If $i <> UBound($Array1) - 1 Then
ReDim $aaHousingArray[ubound($aaHousingArray)+1]
EndIf

Next

that took forever to edit, was there a change in the text input tools?

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...