swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swarm-Support] trouble using an index


From: Eric McLeskey
Subject: [Swarm-Support] trouble using an index
Date: Fri, 7 May 2004 15:47:09 -0600

First, I'm relatively new to this so please bear with me...

I'm getting a complile error while trying to so what seems to be a fairly
basic routine with a list.  (What I think I am doing...) is creating an
index and creating a generic object (element) to be assigned to each
successive item in a previously created flowfieldList.  What I've done is
very similar to what is described in the swarm user guide.  When I complile,
I get an "incompatible types in assignment" error when I try to use
"element" to access a value from the object in the list.  For example, the
following lines receive the error:

elementX = [element getXPos]
elementY = [element getYPos]

I've attached my code.  I've been staring at this for almost 8 hours trying
to figure it out and I'm close to beating my head against the wall.  I'm
running swarm 2.2 pretest 11 on windows XP using cygwin if this may be
relevant...

Thanks for any help,
Eric


-step{
 id <List> nodesICanSee;
 id <Index> flowfieldIndex;
 id element = nil;

 id <Index> localNodeIndex;
 id localElement;
 id idealNode;

 float extentOfView = 10.5;
 float xLow, xHigh, yLow, yHigh, newX, newY;
 float elementX, elementY;

 xLow = [brownNode getX] - extentOfView;
 xHigh = [brownNode getX] + extentOfView;
 yLow = [brownNode getY] - extentOfView;
 yHigh = [brownNode getY] + extentOfView;

 nodesICanSee = [List create: [self getZone]];
 flowfieldIndex = [flowfieldList begin: [self getZone]];

 while((element = [flowfieldIndex next]) != nil){
        elementX = [element getXPos];       
        elementY = [element getYPos];    

        if(elementX > xLow && elementX < xHigh && elementY > yLow &&
elementY < yHigh)
                [nodesICanSee addLast: element];
 }
 [flowfieldIndex drop];

 localNodeIndex = [nodesICanSee begin: [self getZone]];
 float nodeDepth = 1.0;

 while((localElement = [localNodeIndex next]) != nil){
         if (nodeDepth < [localElement getDepth]){
                nodeDepth = [localElement getDepth];
                idealNode = localElement;
         }
 }
 newX = [idealNode getXPos];
 newY = [idealNode getYPos];

 [brownNode moveX: newX Y: newY];

 return self;
 }


Eric McLeskey
Graduate Student
Institute for Natural Systems Engineering
Utah State University
1600 Canyon Road
Logan, UT  84321

phone: (435) 797-8039
fax:  (435) 797-8038
address@hidden


<<attachment: winmail.dat>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]