LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to continually poll the panel for events without a big while loop labview 6.1 "Windows 98"

I think putting a big while loop around a block diagram containing event structures is an ugly way of continually polling for events. This is not required in Visual C++ because of the use of a message map. Is there a more sophisticated way of continually running a program without a while loop.
0 Kudos
Message 1 of 4
(2,639 Views)
For those of us who started LabVIEW when you actually did have to poll the front panel controls, the event structure is a beautiful way of doing things and isn't ugly at all. Imho, it combines the best features of LabVIEW data flow and text based event programming and I don't think there is any more sophisticated method.
Message 2 of 4
(2,639 Views)
Hi,

How about pressing "Run Continuously". It's not more sophisticated, but the
program will keep running!

Your comparation is not entirely fair. In VC++ there *is* a loop
around the message handler, otherwise it would be executed only once! It is
only less obvious.

Your statement about "continually polling for events" is simply not true.
The events are not more or less polled then in a C++ program. By making an
event structure, LabVIEW knows to jump to that peace of code when a windows
message is send. It is exactly (e.g. as close as you can get) like doing:

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,WPARAM wParam, LPARAM
lParam)
{
switch (uMsg)
{
case WM_MOUSEDOWN:
{
execute_mous
e_down_event_structure_content
return 0;
}

The event structure is not continuously polling!

If you want to make subvi's with events in them, that is possible, but only
in LV7. This is actually beneficial, because the subvi's can be reused (even
within the same program).

Regards,

Wiebe.



"Recce" wrote in message
news:5065000000080000004FD00000-1079395200000@exchange.ni.com...
> I think putting a big while loop around a block diagram containing
> event structures is an ugly way of continually polling for events.
> This is not required in Visual C++ because of the use of a message
> map. Is there a more sophisticated way of continually running a
> program without a while loop.
Message 3 of 4
(2,639 Views)
> I think putting a big while loop around a block diagram containing
> event structures is an ugly way of continually polling for events.
> This is not required in Visual C++ because of the use of a message
> map. Is there a more sophisticated way of continually running a
> program without a while loop.

There is a way, but I think you will find that it complicates things a
bit. Callback systems pretty much require that you use pointers to link
your objects together or have global access to everything referenced in
your event handler. Which is also ugly, just in a different way. I've
used both, and I think the one in LV that lets you keep event code more
closely integrated with the panel, lets you use shift registers and
implicitly linked proper
ty nodes.

If you want to build your own event dispatcher, you put VI References
into a data structure with enums indicating who and what you are
interested in registering in. You then read the data and register for
usage in a common subVI. Then when the events take place, you use the
call by reference to call the subVIs. Someday we might have a generic
framework for this, but like I said, I prefer what we have now.

Greg McKaskle
Message 4 of 4
(2,639 Views)