Loop + Illegal expression in evaluator

0

I'm downloading multiple files (one after the other) for a loop , but as soon as I download the first one, it crashes. Here is the loop :

  for x := StrToInt(version)+1 to StrToInt(version2) do
  begin
    url := baseurl+'/'+IntToStr(x)+'.7z';
    BaixarArquivo(IdHTTP1, url, x);
    if pexit = true then break;
  end;

At line if pexit = true then break; when I put the mouse on it, it gives the message:

  

Break = Expression illegal in evaluator.

How can I avoid this error?

Edit: I discovered that the error is inside the DownloadFile function. This line:

downloadedf[high(downloadedf)+1] := IntToStr(Name) + ExtractFileExt(Url);

Where

IntToStr(Name) tem o valor de '1'. (String)
ExtractFileExt(Url) tem o valor de '.7z'. (String)

And I have already stated:

downloadedf : array of string;

And above the error line:

SetLength(downloadedf, Length(downloadedf) +1);

Is there something wrong?

    
asked by anonymous 19.10.2014 / 13:00

2 answers

1

Imagine that as soon as you declare the array:

downloadedf : array of string;

And then at this point, your array has Length 0 (% with%)

The function Length(downloadedf) = 0 is used to get the size, in an empty array it is 0 and then it is the actual size.

The function Length() is used to get the lowest index of an array, if it is empty it is -1, otherwise it returns the lowest index, which is usually 0

The function Low() is used to get the highest index of an array, if it is empty it is -1, otherwise it returns the highest index, which usually equals High()

So, after increasing the size of the array with Length() - 1 , SetLength will already return the last index of the array in question

    
20.10.2014 / 16:34
1

The error was in:

downloadedf[high(downloadedf)+1]

I was already increasing the length before and tried to enter a value in a nonexistent field. I just took the +1.

    
19.10.2014 / 16:25