Hi everyone, I just wrote some clunky code for a twincontrol helper but in retrospect is there a better way to determine if a twincontrol already contains a child control with a particular name?
I’ve seen the method containsthiscontrol() but that doesn’t work for the name. As you all probably know, duplicate names cause a crash. If I remember correctly, more than one unnamed control will also be interpreted as duplicate names.
here is what i did
FUNCTION TWINCONTROL_HELPER.CONTAINS_NAME( CONST ANAME: STRING) : BOOLEAN;
VAR X:INTEGER;
BEGIN
FOR X:= 0 TO {SELF.}ControlCount -1 DO
IF UPCASE(Controls[X].NAME) = UpCase(ANAME)
THEN EXIT(TRUE);
RESULT:= FALSE;
END;
Another strange thing is I couldn't get the controlcount to appear in the helper autocomplete list without typing self first. i have often noticed that the auto complete behavior inside helpers doesn't seem to work as well as other places..