Author Topic: Set::add:: Object doesn't exist  (Read 1436 times)

I am reading lines from a file and adding them to a ScriptGroup. Once the size of the group is 50, the code sends all the objects in the Scriptgroup to a TCPobject, then empties the Scriptgroup.

Code: [Select]
%bufferSz = 50; //50 brick lines per JSON command
%liBroup = new ScriptGroup();

while (!%f.isEOF())
{
%currL = %f.readLine();
%currL = strReplace(%currL, "\"", "\\\"");
%linesRead++;

if (%liBroup.getCount() == %bufferSz)
{
%sendCmd = "{\"cmd\": \"UPLOAD_LINES\", \"sessionID\": \"" @ %this.sessionID @ "\", \"lineCt\": \"" @ %liBroup.getCount() @ "\", \"lines\": [";

for (%i = 0; %i < %liBroup.getCount(); %i++)
{
if (%i + 1 < %liBroup.getCount()) //not the last iteration
%sendCmd = %sendCmd @ "{\"" @ %i @ "\": \"" @ %liBroup.getObject(%i) @ "\"}, ";
else
%sendCmd = %sendCmd @ "{\"" @ %i @ "\": \"" @ %liBroup.getObject(%i) @ "\"}";
}

%sendCmd = %sendCmd @ "]}";
%this.tcpObj.sendJSON(%sendCmd);
%liBroup = new ScriptGroup(); //this empties the group, by creating a new object
}

%liBroup.add(%currL);
echo("IBL client: Added line to group. %liBroup's value: " @ %liBroup);

if (%f.isEOF()) //last line
{
%sendCmd = "{\"cmd\": \"UPLOAD_LINES\", \"sessionID\": \"" @ %this.sessionID @ "\", \"lineCt\": \"" @ %liBroup.getCount() @ "\", \"lines\": [";

for (%i = 0; %i < %liBroup.getCount(); %i++)
{
if (%i + 1 < %liBroup.getCount()) //not the last iteration
%sendCmd = %sendCmd @ "{\"" @ %i @ "\": \"" @ %liBroup.getObject(%i) @ "\"}, ";
else
%sendCmd = %sendCmd @ "{\"" @ %i @ "\": \"" @ %liBroup.getObject(%i) @ "\"}";
}

%sendCmd = %sendCmd @ "]}";
%this.tcpObj.sendJSON(%sendCmd);
}
}

Then I get these console errors, every time a line is read:

Code: [Select]
Set::add:: Object "2x2F\" -80.5 -68 6.7 0 0 15  0 0 1 1 1" doesn't exist

The string inside the quotes varies depending on what brick it is.
« Last Edit: May 24, 2014, 12:27:06 PM by Hammereditor5 »

%currL is a string.

A set can only contain objects. A string is not an object...

So I just make a Script object class to hold a string?

So I just make a Script object class to hold a string?

Why do you even need a scriptgroup? Just use an array.

Why do you even need a scriptgroup? Just use an array.
Yeah, this is what I decided to do in the end.