06-09-2009 10:26 AM - edited 06-09-2009 10:27 AM
Dear All,
this might be an easy Question but i couldn't catch an answer for it.
first of all i have a VI which i will use as a subVI , this VI is simply as shown in the "test_out of scope.vi" attached file
now i will use it inside another VI called "Main VI" as shown in the file "Main_VI.vi"
i'm just wondering , why couldn't i control the "Frequency" and "Stop" as i can do so while running the SubVI only without accessing it from another VI ?
isn't it possible to access objects inside a while loop from another VI if i just connected them in the connection Pane terminals ??
Thanks in advance to everybody
06-09-2009 10:32 AM
Being a CLAD, you should realize why that cannot be.
If you are using a While Loop and within the While Loop you call a VI, then the VI has to complete execution and exit befor the While Loop completes it's iteration.
What you want to do is call the sub-vi externally to that loop. You may use a variety of approaches to changes values within the sub-vi, such as using references or queues.
R
06-09-2009 10:56 AM
i totally understand this
the point is that i was preventing using Global variables , maybe a more efficient way or something
also i thought of using a Control reference to modify the controls instances inside the While loop
posting here really teaches me alot , even if i was knowing an answer , i may expect a better one
there are 2 kinds who never learn , the ignorant and the shy
Regards...
06-09-2009 12:10 PM
06-09-2009 12:53 PM
yeah , but i just posted an example illustrating the problem , in this case no need for the while loop but in other cases it is the main part of the code
06-09-2009 01:45 PM
Why would it be the main part of the code? The top level has a while loop so why do you want to repeat that?
06-09-2009 02:20 PM
06-09-2009 02:27 PM
Dennis , you are talking general ? or still stuck to this piece of code i've uploaded ?
if you are talking general , then u mean i can replace any while loop inside the subVI with a while loop in the main VI instead ?
Regards
06-09-2009 02:43 PM
Do you need the sub-vi to run iterations for an undertermined period of time?
If so, then why not implement it as a parallel loop to the main one. Maybe part of a consumer loop.
If not. Where the main loop would take care of each iteration and call the sub-vi in one shot. Then no need for a loop in the sub-vi.
It's all a matter of how you want the software to behave. Have you looked at Event Structures?
R
06-09-2009 02:46 PM