Author Topic: getLine is not recognizing the last line  (Read 681 times)

This was working last night, but it decided to stop working for some reason. The problem is inside the for loop, when it echoes  the page I see the last line perfectly fine.
Code: [Select]
function ZapkCRPG_HTTP::onDisconnect(%this)
{
%page = %this.page;
echo(%page);
for(%a = 1; %a < getLineCount(%page); %a++)
{
%line = getLine(%page, %a);
if(firstWord(%line) $= "<latestVersion>")
{
$ZapkCRPG_HTTP_latestVersion = restWords(%line);
//echo("\c4Downloaded Version:" SPC $ZapkCRPG_Version);
//echo("\c4Latest Version:" SPC $ZapkCRPG_HTTP_latestVersion);
}
if(firstWord(%line) $= "<releaseDate>")
{
$ZapkCRPG_HTTP_releaseDate = restWords(%line);
//echo("\c4Update Released:" SPC $ZapkCRPG_HTTP_releaseDate);
}
if(firstWord(%line) $= "<downloadLink>")
{
$ZapkCRPG_HTTP_downloadLink = restWords(%line);
//echo("\c4Download Link:" SPC $ZapkCRPG_HTTP_downloadLink);
}
if(firstWord(%line) $= "<rtbID>")
{
$ZapkCRPG_HTTP_rtbID = restWords(%line);
//echo("\c4RTB ID:" SPC $ZapkCRPG_HTTP_rtbID);
}
}
if($ZapkCRPG_Version != $ZapkCRPG_HTTP_latestVersion)
{
%mcText = "A new version (" @ $ZapkCRPG_HTTP_latestVersion @ ") was released on" SPC $ZapkCRPG_HTTP_releaseDate @ ".";
clientCmdZapkCRPG_mc("Update Available!", %mcText);
if(isObject(RTBMM_TransferQueue) && $ZapkCRPG_HTTP_rtbID !$= "")
{
//Thanks Greek2Me for the notification code <3
if(isObject(RTBCC_NotificationManager))
{
RTBCC_NotificationManager.push("Zapk's City RPG", "Downloading client updates.", "new", "", 5000);
}
RTB_ModManager.setVisible(1);
RTBMM_TransferView_Init();
RTBMM_TransferQueue.addItem($ZapkCRPG_HTTP_rtbID);
}
}
else
{
echo("\c4Client up-to-date.");
}
}
When I try to echo $ZapkCRPG_HTTP_rtbID, it doesn't return anything. Obviously my for loop isn't recognizing the last line. When I force it to go higher, it says Index out of rande (0-3, 4), when there is obviously a fifth line there.

Oh, and here's the page it's reading off of.
http://pastebin.com/raw.php?i=jmvwzy58
It isn't recognizing the <rtbID> line inside the for loop.

Are you intentionally skipping the first line (Line 0)? Otherwise, just check if %a is less than or equal to (<=) getLineCount(%page) to read another line.

Are you intentionally skipping the first line (Line 0)? Otherwise, just check if %a is less than or equal to (<=) getLineCount(%page) to read another line.
Yeah, line 0 is always blank.

I don't have a copy of Blockland so I can't actually crack it open and test this for you, but what you're saying doesn't make sense. If echo shows 5 lines and getLineCount() returns 4 and refuses to read a line over 3, then you've discovered a bug and you'll have to find a new way to do it. Personally I think you should just parse it onLine(%this, %line) rather than parsing it after it disconnects. Then you don't have to deal with getLine, or storing the data, at all.

I don't have a copy of Blockland so I can't actually crack it open and test this for you, but what you're saying doesn't make sense. If echo shows 5 lines and getLineCount() returns 4 and refuses to read a line over 3, then you've discovered a bug and you'll have to find a new way to do it. Personally I think you should just parse it onLine(%this, %line) rather than parsing it after it disconnects. Then you don't have to deal with getLine, or storing the data, at all.
Hm...
Will try this.