"iusn" <x@no.email> wrote in message news:1156952408221-410369@exchange.ni.com...
Thanks to all for your answers!
Wiebe! I tried to do as you suggested but I am not able to link the Event Reference Number inside te SubVI with the Event Register Number of the Register for Event in Main VI. There is e class conflict. Another question: how the SubVI can know the structure of the Register event outside?My aim was to create a modular structure but it seems very difficult, wath do you think about these problems?
The broken wire is related to your question. The event structure inside the sub vi knows about the events you register in the main, because the reference wire/control has a "strong" type. It contains information about the registered events. That is also why the wire is broken. You have to register all events, then create an indicator/control of the output. Use that control in the subvi. You have to do this every time the events change (you might use a type def if you use the control a lot).
Usually, the events that you would want to put inside subvi's are those related to user interface objects. I've had this a lot. You make a nice interface, but it's not reuseable, because the events are mixed with all the other events. Only solotion is to manually add the needed event cases in your program, and copy the code.
Even if you can put the events in a sub vi, I'd expect hanging vi's when more subvi's are registered for the same event. It's hard to tell without trying. So it's not a real solution either.
Like Chrisger suggested, the event callback might help a little, but they are tricky, and actually ment for this (they are intended for activex callbacks).
Perhaps you should look at XControls (if you use 8.2). It would be more work to replace your code to XControls, but once you're done, you have reusable code.. Haven't worked with them jet, but they are invented for this problem...
Regards,
Wiebe.
I have already create my application using event structure just in Main VI but it seems very complicate to read and keep update, I would have wanted to give modularity to my application.
Thanks Ius
SubVIEventMain.vi:
http://forums.ni.com/attachments/ni/170/203225/1/SubVIEventMain.vi
SubVIEvent.vi:
http://forums.ni.com/attachments/ni/170/203225/2/SubVIEvent.vi