Dear Sir,
I have Created a recursive Function called SetLevel which has two Parameter one is
Para1 ( Datatype Code) and another is
Para2 ( Datatype Integer), and Para2 is using as Pass by Reference.
I Want this function should return the Para2 as Return Value (Return Type Integer).
Is it Possible as the way I want ?
Tab.Field :=SetLevel (Value1,Value2)
Tab.Modify;
Function SetLevel(HierarchyNo,Level)
Level +=1;
Cust2.SETRANGE("Hierarchy No.",HierarchyNo);
IF Cust2.FINDFIRST THEN
BEGIN
HLine2.SETRANGE("Customer No.",Cust2."No.");
IF HLine2.FINDFIRST THEN
BEGIN
SetLevel(HLine2."Hierarchy No.",Level);
END
ELSE
EXIT(Level);
END;
Here SetLevel does not give the value where
value2 gives.
What is the reason ?
Kindly reply.
Thank you.
Comments
Already I have used this method. But I want to know from you Sir.
Is it not possible in the way I want ?? :-k
BTW Thank you Sir for your reply. =D>
Use EXIT(Para2) or assign Para2 to the name you have given the return parameter.
From your code sample it is unclear "the way I want".
The function SetLevel needs to define a return type. The way you gave it to us, a compile error will result.
Moreover make sure the desired return value is defined on any way out.
And then, this code is VERY liekely to produce endless loops. You need to saveguard against it.
already done
I want that The function should return the desired result not the variable only.
Already done Still not facing any error.
Moreover make sure the desired return value is defined on any way out.
And then, this code is VERY liekely to produce endless loops. You need to saveguard against it.