LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating CSV file according with the international settings

Hello,

 

I often create buttons in my applications, that create CSV files extracting technical data from binary files. This allow my collegues to analyze data using Excel, MatLab, Minitab etc..

Depending on the Internation Settings of each computer, the CSV file should be created using comma, semicomma, etc. (List Separator character).

Is there any function in LabWindows to get the List Separator character, that appears in Control Panel+Clock, Language and Region+Region & Language+Advanced Settings?

 

Thanks

 

Sergio

0 Kudos
Message 1 of 14
(5,330 Views)

You can try digging the Win SDK for an appropriate function, as I don't remember of a CVI function that retrieves this value.

 

Looking into msdn I have found this page that can be of interest: basically it seems that you must call GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SLIST, buffer, 4); next you must use the first character in the returned string which should be the active one.

 

I never tried to retrieve such value but I will check myself as this element can be of interest for me too.



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 2 of 14
(5,322 Views)

Hi Roberto,

 

surely I'll experiment your suggestion.

 

Thank you

 

0 Kudos
Message 3 of 14
(5,306 Views)

Hello Sergio,

I made some tests here and the solution I proposed works correctly, provided it is trimmed a bit.

 

The base key is that CVI SDK sets WINVER macro to too low a level to handle this function (see this post from LuisG to understand this point). As suggested by Luis, adding  /DWINVER=_WIN32_WINNT_LONGHORN (it sets version to Windows Vista: you may want to target higher systems if you want) to Compiler defines field in Predefined macros window did the trick and the code now works as expected on my machine (a Win7 box); you don't need to add kernel32 library to your project as it is already loaded by CVI as reported here.

 

This is a test code to check function results:

#include <windows.h>



	char	msg[8];

	GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SLIST, (LPWSTR)msg, 8); 
	DebugPrintf ("List separator: %s\n", msg);

It returns the active list separator, i.e. the one effectively used by the system, even if you have more than one character listed in the combo boc from regional settings dialog in Control panel.

 



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 4 of 14
(5,268 Views)

Hi Roberto,

 

Unfortunately I don't have SDK installed and it really looks like too much complex for my knowledges (and also for the time I can spend on this topic).

Hoping your work may be useful to someoneelse, I'd like to thank you for your efforts, I do really appreciate.

 

Best regards

Sergio

0 Kudos
Message 5 of 14
(5,275 Views)

Well, my approach to this issue has been slightly different, my software provides a ring control allowing the user to select a separator, e.g., tab, space, comma or dot.

 

But since Roberto provided this 'ready-to-try' answer I thought to try it myself, without writing a program but using the Interactive Execution window instead.

Unfortunately, this results in an error (error: implicit declaration of function 'GetLocaleInfoEx' is invalid in C99. Make sure that you include the function prototype.) even if I have deselected C99 build options. So I would like to ask Luis how one could set compiler defines for the interactive execution mode...

 

Thanks!

0 Kudos
Message 6 of 14
(5,274 Views)

As of CVI2012 the code can be executed in the Interactive Execution window.

 

At some time I should switch forward to a newer release, but every now and then I meet some surprises like this and I feel discouraged...



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 7 of 14
(5,270 Views)

...but not anymore in CVI2015... (at least not the way I tried Smiley Wink)

 

I wouldn't feel discouraged, I think that the new clang compiler is a very good reason to upgrade

0 Kudos
Message 8 of 14
(5,268 Views)

Hi Wolfgang,

 

I don't think that that missing prototype error has anything to do with the interactive window. Do you not see the same error if you were to paste that code into one of your project files?

 

That error is more than likely happening because you didn't specify a higher OS version, via WINVER. By default, CVI sets WINVER to the oldest OS version that CVI supports (XP?). This is good enough for most of the Windows API, but if you are trying to use a newer function, and you know that you will never be running your program in an older OS, then you should override the WINVER value, by adding the following (for example) to the Build Output window:

 

/DWINVER=_WIN32_WINNT_VISTA

 

(because GetLocaleInfoEx was added for Vista)

 

Once you do this, I bet you won't see that compile error any more.

 

Also, to answer your question about the interactive window, when you compile this window, CVI applies the settings (compiler defines, etc) from your currently selected build configuration (Build>>Configuration>>...)

 

Luis

 

 

0 Kudos
Message 9 of 14
(5,237 Views)

Hello Luis, help me understanding this issue 'cause I don't afford to make it working.

I am trying to execute the code in the interactive window in CVI2013SP2 (yes, I have it installed even if I'm not using it in production Smiley Wink ) after having set WINVER to VISTA as you suggested.

 

With this code:

 

#include <windows.h>
#include <utility.h>

static char	msg[8];

GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SLIST, (LPWSTR)msg, 8); 
DebugPrintf ("List separator: %s\n", msg);

 

I get the error:

 

Interactive Execution - 1 error
  1, 1 error: Unresolved symbol: _GetLocaleInfoEx@16

 

Adding kernel32.lib in the project has no effect (I supposed so, since it should be already loaded but I tried anyway).

 

Also, are those macros we are adding to build options per-project or permanent on all projects?



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 10 of 14
(5,226 Views)