const grpNodeCount  : Integer = 1; //not a true constant 

haveing set the compiler flag for assignable constans.

Bob pointon

>>> [EMAIL PROTECTED] 15/12/2005 02:31:43 >>>
Hello. This isn't really necessary but we all know that using global 
variables isnt a good convention. But in same cases it can't be helped.
Here 
is such a case. What this recursive function does is extracts all the
child 
objects that are grouped together as a single object. The single object

itself is not a real object but rather treated as one. So there is no
parent 
except for the group itself. Now these objects could be a sibling or a
child 
and thus are in the heirachy in a certain way. With this function, it
doesnt 
matter, it checks and gets them anyway. What I need help with is to
find a 
way to make grpNodeCount local instead of global. If I made
grpNodeCount 
local, it is always reinitialized to 0 no matter what I do, so I had to
make 
it global to keep its value. I need to initialize it 0 before and after
a 
call to this function  I just thought of something, what if I made 
grpNodeCount a variable in the function itself? That way it would keep
it's 
value and keep it local. What do you think?

// tsxGNode, tsxGroup, etc are all pointers to empty structures
PObjArray = array of tsxGNODE;

procedure tsGrpExtractNodes(grp: tsxGROUP; var nodes: PObjArray);
var
  pChildNode: tsxSOBJ;
  objtype: tsxSOBJTYPE;
begin
  pChildNode:= tsxGNodeGetFirstChild(grp);
  while (pChildNode <> nil) do begin
    objtype:= tsxSobjGetType(pChildNode);
    if ((objtype = e_tsxGROUP) or (objtype = e_tsxIKGROUP)) then begin
      grp:= pChildNode;
      tsGrpExtractNodes(grp, nodes);
    end
    else begin
      nodes[grpNodeCount]:= pChildNode;
      grpNodeCount:= grpNodeCount + 1;
    end;
    pChildNode:= tsxGNodeGetNext(pChildNode);
  end;
end;
__________________________________________________
Delphi-Talk mailing list -> [email protected] 
http://www.elists.org/mailman/listinfo/delphi-talk
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to