11-04-2017 11:27 AM
Hello ,
I want to include and display the date and time in the Title Panel of the project, but when I start the program I got an error NON-FATAL Error. Here is the code of mine. I would like to ask what is missing to my code. The utility.h already included in the header.
GetProjectDir(projdir);
//sprintf(szTmp,"%s\\%s_dbg.exe",projdir,szSoftwareName);
sprintf(szTmp,"%s\\%s_v1.1.exe",projdir,szSoftwareName);
GetFileTime (szTmp, &hr, &min, &sec);
GetFileDate (szTmp, &mon, &day, &yr);
sprintf(szTmp,"%s %d/%d/%d %d:%d:%d %s %s",szSoftwareName,mon,day,yr,hr,min,sec,szAuthor,SW_Version);
SetPanelAttribute (panelHandle_Cobot, ATTR_TITLE, szTmp);
NON-FATAL RUN-TIME ERROR: Function CVI_GetFileTime (return value ==-1)
Solved! Go to Solution.
11-04-2017 12:09 PM
Hello,
the return value of -1 tells you that the file or the directory have not been found (I assume that the last line of your post is not the original output of CVI... since in your code you have GetFileTime and not CVI_GetFileTime). So I suggest to have a look at your szTmp...
Good luck!
11-04-2017 01:06 PM
I would also suggest the use of MakePathname to build up the file pathname in a friendly manner without need to struggle with single/double backslashes.
11-11-2017 07:41 PM
Is someone can share their working function regarding GetFileTime and GetFileDate?
Because I tried your suggestion but still the same error occurred.
Thanks,
11-12-2017 10:44 AM - edited 11-12-2017 10:45 AM
Hi, try this. It's the main function of a project where the panel is loaded and titled with the date and time of the executable. It makes use of argv[0] argument of the main functions that always holds the value of the program in execution (other command line parameters, if any, are listed from argv[1] on).
int main (int argc, char *argv[]) { int dd, mm, yy, hh, mn, ss; char file[1024]; if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelHandle = LoadPanel (0, "FileDateAndTime.uir", PANEL)) < 0) return -1; // Create executable pathname GetProjectDir (file); MakePathname (file, argv[0], file); // Get file date and time and update window title GetFileDate (file, &mm, &dd, &yy); GetFileTime (file, &hh, &mn, &ss); sprintf (file, "Window [%d %d, %d (%02d:%02d:%02d)]", mm, dd, yy, hh, mn, ss); SetPanelAttribute (panelHandle, ATTR_TITLE, file); DisplayPanel (panelHandle); RunUserInterface (); DiscardPanel (panelHandle); return 0; }
11-12-2017 01:10 PM
Thanks Robert for the usual support.