Jump to content

computation efficiency arrays


Recommended Posts

I asked a question today about StringRegExp(). Now this works, but i have a problem. I do this multiple times and i need to store all these requests in one array. I have a little idea what the size will be, but its better if i have an array with the correct amount of entries instead of some empty entries right? now after each add the array redims and its not a good solution. My code:

dim $i,$currentsize,$newsize,$totallinks[1],$links[0]
do
$i=$i+1
$hResponse=getresponse($i)
$currentsize=Ubound($links)
local $links[2]=StringRegExp($hResponse,"(?:link.asp\?id=)(\d+)",3)
$newsize=Ubound($players)
sleep(100)
_ArrayConcatenate($totallinks, $links)
Until ($currentsize=$newsize)

now $totallinks should contain all the links? don't worry about my function getresponse(), it just gets a new html string with data for every $i.

Edited by cageman
Link to comment
Share on other sites

You can't have an array of zero elements: $links[0].

Maybe something like this?...

Dim $i, $currentsize, $newsize, $totallinks[1], $links[1]

Do
    $i = $i + 1
    $hResponse = getresponse($i)
    $currentsize = UBound($links)
    _ArrayAdd($links, StringRegExp($hResponse, "(?:link.asp\?id=)(\d+)", 3))
    $newsize = UBound($players)
    Sleep(100)
    _ArrayConcatenate($totallinks, $links)
Until ($currentsize = $newsize)
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...