From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

G#

cancel
Showing results for 
Search instead for 
Did you mean: 

Recursive call in g# class method.

Hey,

I've a base class A, with abstract method DO().

Then derrivative class B, which contains array of A objects.

Now I've implemented DO() method, which need to recurse on each element of array. So I'm calling DO() method for each item.

I'm getting the error message, attemped to do recursive call.

What should I do?

Thanks.

0 Kudos
Message 1 of 5
(6,437 Views)

Hi davkh!

I'm trying to understand what you are doing and recreating such code, but I don't understand exactly what it is you are trying to do. Have you set the DO-method to 'shared clone'? If the VI is not enabled to run reentrantly, you will get the error you see. Hope that helps.

cheers!

Certified LabVIEW Architect
0 Kudos
Message 2 of 5
(5,172 Views)

Yeah man,

I've already done that. And yes, that is the solution.

And about recreating, I've tried to explain as simple, as possible. In a real, I'm doing much difficult architecture, using many OOP features, like polymorphism.

Thanks for advice, in all cases.

0 Kudos
Message 3 of 5
(5,172 Views)

Hi,

There is nothing special about G# and recursion, since G# simply is a LabVIEW class and will follow all the rules regarding recursion as are allowed for LabVIEW classes. I've used a lot of G# recursion and never had any problem when setting the "shared clone" in the VI execution property just as Thomas mension above. You also must make sure you have a stop condition for the recursion and that usually causes the recursive call VI to be inside a case structure. I think that you can get a similar error if the LabVIEW compiler identifies a possible infinit recursive call.

Mattias

0 Kudos
Message 4 of 5
(5,172 Views)

Thanks Mattias,

I'm not new in programming, and I know well about recursion, and it's basis.

0 Kudos
Message 5 of 5
(5,172 Views)