LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

"How to make the system time display with time going on ,not just a moment,until click "Exit" button?And how to sperate the date and time string using "space"?

Pls see the attached CVI programm. I want to display the system time with time going on ,not just a moment,until click "Exit" button.But now what i can do is just display some moment's display.What modification should i do to realize it?Maybe add a loop?What is the best solution for it?" Another question is how to sperate the date and time string in one control display? Thanks.
0 Kudos
Message 1 of 3
(2,992 Views)
Add a timer to your program:
1. In the UI Editor, right-click on empty space in your panel and select Timer.
2. Double-click on the timer to edit the control.
2.1 Add a Callback Function name, e.g. TimerCallback.
2.2 The default timer interval is 1 second. If you want to update your display at a different rate, change the Interval.
2.3 If you want to change the timer label from Untitled Control, change it. (The label isn't used by anyone. The user won't see it at run-time).
2.4 Click OK to stop editing the control and return to the UI Editor.
3. Right-click on the timer and select Generate Control Callback.
4. Right-click on the timer and select View Control Callback.
5. Do something like this to get and format the time and date.

int CVICALLBACK TimerCallba
ck (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char timeAndDate[80];
switch (event)
{
case EVENT_TIMER_TICK:
sprintf (timeAndDate, "%s %s", TimeStr (), DateStr ());

SetCtrlVal (panelHandle, PANEL_TIMESTRING, timeAndDate);

break;
}
return 0;
}
0 Kudos
Message 2 of 3
(2,992 Views)
P.S.
When you post your project, it would be helpful to include the .PRJ project file. You don't need to include the .CDB or .EXE files. With the .PRJ file, we can easily recompile your project.
0 Kudos
Message 3 of 3
(2,992 Views)