The function isn't recursive, because the rec position in the table reccmp is not preserved in a loop after a call. The position of current record is "the side effect" of function and shouldn't be used to control the
while loop.
>FUNCTION PEGAINS
>LPARAMETERS CODCOMP
>SELE RECCMP
>GO TOP
>=SEEK(CODCOMP,'RECCMP','ind1')
>DO WHILE CODCOMP = RECCMP.IDCMP AND !EOF()
> IF !ISNULL(CHILDIDCMP)
> =PEGAINS(CHILDIDCMP)
> ELSE
> ? allt(str(IDCMP))+' - '+allt(str(IDISM))
> ENDIF
> SKIP
>ENDDO
_________________
*|| Andrzej [NJ].