LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

error when file name with accent passed to GetFileDate()

Solved!
Go to solution

Hi,

 

When i pass a file or a file that belongs to a path that has one of its folders names containing an accented character to GetFileDate(), i get a Library function error (return value == -1). For example all files within the folder 'Eéprom' return an error. Can anyone please offer some help on how i resolve this issue?

 

Thank you!

 

(LabWindowsCVI 9.0 / Windows 2000 / CVIRTE2009)

0 Kudos
Message 1 of 12
(4,876 Views)

I think part of the problem is that   DIR_GetFileList()   does not get the accented file names correctly. Is there another function i have to use to get the file list with the file names with accented characters displayed correctly? Due to this the file names with accents are not displayed properly on my table. However when i use FileSelectPopup() to choose a file to add to my table it displays perfectly with the accent. Can someone please help. Thanks.

0 Kudos
Message 2 of 12
(4,863 Views)

I am not aware of a CVI function DIR_GetFilelist...

0 Kudos
Message 3 of 12
(4,861 Views)

Oh yes ur right Wolfgang thats a custom function. Im not sure what i need to change in that function in order for it to acquire the list of file names with the accents displayed properly. This is what it does at the moment : 

 


MakePathname(ProjectDir, "tmp_lst.txt", TxtFile);
MakePathname(ProjectDir, "tmp_lst.bat", BatFile);

bat_file = fopen(BatFile, "w");
fprintf(bat_file, "@echo off\n");
fprintf(bat_file, "dir /s /b /a-D \"%s\\*.*\" > \"%s\"\n", directory, TxtFile);
fclose(bat_file);

system(BatFile);
DeleteFile(BatFile);

txt_file = fopen(TxtFile, "r");

 

 

Any idea? Thank you !

 

 

 

0 Kudos
Message 4 of 12
(4,852 Views)

Hello sinnas!

 

As Wolfgang mentioned, DIR_GetFileList isn't part of the CVI Utility Library. Is that a customized user-defined function that you are using to pass the file name over to CVI GetFileDate?
Moreover, GetFileDate appears to be handling accented file names correctly even with CVI 9.0 and CVI 2013.

 

Have you tried calling GetFileDate explicitly for that file name, for instance, from the Interactive Execution window? That is, without using the file name strings provided by DIR_GetFileList.

 

0 Kudos
Message 5 of 12
(4,851 Views)

Hello sinnas!

 

After seeing your last post, I determined that the problem is actually in your BAT script. The dir /s /b /a-D \"%s\\*.*\" > \"%s\"\n command is not interpreting the accents correctly. You can make a simple test in a command prompt window to determine that.

 

In order to fix the problem you would have to set the code page of the command prompt running your BAT script accordingly.

Here are some community forum posts that address the exact issue you are experiencing:

http://stackoverflow.com/questions/7584423/problem-running-bat-cmd-file-with-accented-characters-in-...

http://stackoverflow.com/questions/1427796/batch-file-encoding

 

I hope this helps!

Message 6 of 12
(4,845 Views)

So if you have the code why don't you step through it...: for example, what's the contents of ProjectDir, is it o.k. or does the problem occur already earlier? If it is o.k., is TxtFile also o.k.? ...

 

Also, it is always useful to analyse the return value of functions, e.g. status = MakePathname ()

0 Kudos
Message 7 of 12
(4,844 Views)

Johannes i think you are right. Thank you very much i will take a look at the links u have provided.

Thanks Wolfgang, i had the code but was a little lost on what was happenin with the bat files. 

 

Much appriciated. Merci beaucoup. 

0 Kudos
Message 8 of 12
(4,834 Views)

Hi Johannes, thanks for the links. Sorry but could i push you a bit further?, as im not able to get it working. How exactly do i incorporate this chcp 1252 into my code above?

 

Thank you!!!

 

sinnas

0 Kudos
Message 9 of 12
(4,830 Views)
Solution
Accepted by topic author sinnas

You would basically only need to add an extra printing line to your function that creates the BAT file.

Similar to this:

fprintf(bat_file, "@echo off\n");

fprintf(bat_file, "chcp 1252\n");
fprintf(bat_file, "dir /s /b /a-D \"%s\\*.*\" > \"%s\"\n", directory, TxtFile);

 

This should set the code page of the console in which your BAT file is running, so that the dir command will be able to output the accents correctly.

0 Kudos
Message 10 of 12
(4,825 Views)