LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NON-FATAL Error (GetFileTime and GetFileDate)

Solved!
Go to solution

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)

 

 

 

 

0 Kudos
Message 1 of 6
(3,587 Views)

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!

0 Kudos
Message 2 of 6
(3,573 Views)

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. 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 6
(3,567 Views)

Is someone can share their working function regarding GetFileTime and GetFileDate?

Because I tried your suggestion but still the same error occurred.

Thanks,

 

0 Kudos
Message 4 of 6
(3,487 Views)
Solution
Accepted by topic author Master_Viper

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;
}

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 6
(3,478 Views)

Thanks Robert for the usual support.

0 Kudos
Message 6 of 6
(3,473 Views)