Can this task be done a better way?

Can this task be done a better way?

am 27.09.2007 22:32:50 von qwertycat

I have an IQ of a donkey, I'm sure the below code can be done a
different/more intelligent way. It should download headers in chunks
of 5000, rather than all 2 million in one go:

$Newsgroup_Data = $NNTP->selectGroup($Newsgroup_Name);

$First_Article_Number = $Newsgroup_Data["first"];
$Last_Article_Number = $Newsgroup_Data["last"];

$Articles_To_Download = $Last_Article_Number - $First_Article_Number;

while($First_Article_Number <= $Newsgroup_Data["last"])
{
$Last_Article_Number = $First_Article_Number + 4999;
$Articles = $NNTP->getOverview($First_Article_Number,
$Last_Article_Number);
$First_Article_Number = $First_Article_Number + 5000;

// do something with the headers here

unset($Articles);
}

Re: Can this task be done a better way?

am 28.09.2007 13:26:56 von Jerry Stuckle

qwertycat@googlemail.com wrote:
> I have an IQ of a donkey, I'm sure the below code can be done a
> different/more intelligent way. It should download headers in chunks
> of 5000, rather than all 2 million in one go:
>
> $Newsgroup_Data = $NNTP->selectGroup($Newsgroup_Name);
>
> $First_Article_Number = $Newsgroup_Data["first"];
> $Last_Article_Number = $Newsgroup_Data["last"];
>
> $Articles_To_Download = $Last_Article_Number - $First_Article_Number;
>
> while($First_Article_Number <= $Newsgroup_Data["last"])
> {
> $Last_Article_Number = $First_Article_Number + 4999;
> $Articles = $NNTP->getOverview($First_Article_Number,
> $Last_Article_Number);
> $First_Article_Number = $First_Article_Number + 5000;
>
> // do something with the headers here
>
> unset($Articles);
> }
>

What's wrong with what you have?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================