Richard R wrote:
> 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?

The grpNodeCount variable is used to keep track of how many elements in 
the array are filled. Since you pass the array in as a parameter, you 
may as well pass the array's size in as a parameter, too.

procedure tsGrpExtractNodes(grp: tsxGROUP; var nodes: PObjArray; var 
grpNodeCount: Cardinal);

-- 
Rob
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to