No, I declare them global only for code consistence, but it is not needed, a type pointer becomes global the moment you declare it.
So this:
troop.t_troop
has the same effect of:
global troop.t_troop
More, since you return a troop element (this), you can just refer to that, since the for..next loop has exited, that means that 'this' points already to the right element. In other words, you may do like:
FindTroopLeader(troop)
this\checked = true ;'this' points already to the element you want to edit
That's why I think, also, that you can set the 'checked' field of 'this' element, directly in the FindTroopLeader function:
Function FindTroopLeader.unit(troop.troop)
For this.unit = Each Unit
If this\troop = troop
If this\leader = True
EndIf
EndIf
Next
End Function
That means also that the function declaration does not need to return any 'unit' type, so you can declare it as:
Function FindTroopLeader(troop.troop)
Hopefully I didn't confuse you !
Sergio.
So this:
troop.t_troop
has the same effect of:
global troop.t_troop
More, since you return a troop element (this), you can just refer to that, since the for..next loop has exited, that means that 'this' points already to the right element. In other words, you may do like:
FindTroopLeader(troop)
this\checked = true ;'this' points already to the element you want to edit
That's why I think, also, that you can set the 'checked' field of 'this' element, directly in the FindTroopLeader function:
Function FindTroopLeader.unit(troop.troop)
For this.unit = Each Unit
If this\troop = troop
If this\leader = True
;Return this.unit this\checked = true return
EndIf
EndIf
Next
End Function
That means also that the function declaration does not need to return any 'unit' type, so you can declare it as:
Function FindTroopLeader(troop.troop)
Hopefully I didn't confuse you !
Sergio.