LB Booster
Programming >> Liberty BASIC language >> How to read regional setting from OS?
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1392985232

How to read regional setting from OS?
Post by FBack on Feb 21st, 2014, 11:20am

I wonder, if is a possible in the LBB to determine, if the operating system for decimal mark uses a decimal point or a decimal comma?

e.g:
12.3
or
12,3

Best regards
Re: How to read regional setting from OS?
Post by Phineas Freak on Feb 21st, 2014, 3:09pm

You can use the GetLocaleInfo() API to retrieve the Digit Grouping Symbol Decimal Separator symbol:

Code:
  LOCALE.SDECIMAL = 14
  Locale          = 2048
  LCType          = LOCALE.SDECIMAL

  result$ = GetLocaleInfo$(Locale, LCType)

  print result$ : end

'=============================================================================================================

  function GetLocaleInfo$(Locale, LCType)

    lpLCData$ = space$(1024) + chr$(0)
    cchData   = len(lpLCData$)

    calldll #kernel32, "GetLocaleInfoA", _
        Locale        as long,           _
        LCType        as long,           _
        lpLCData$     as ptr,            _
        cchData       as long,           _
        GetLocaleInfo as long

        if GetLocaleInfo <> 0 then GetLocaleInfo$ = left$(lpLCData$, GetLocaleInfo - 1)

  end function
 

Re: How to read regional setting from OS?
Post by Richard Russell on Feb 21st, 2014, 4:06pm

on Feb 21st, 2014, 3:09pm, PreciseTiming wrote:
You can use the GetLocaleInfo() API to retrieve the Digit Grouping Symbol:

To be pedantic it's the Decimal Separator symbol, but your code is correct. Thanks for that.

Richard.

Re: How to read regional setting from OS?
Post by Phineas Freak on Feb 22nd, 2014, 07:17am

on Feb 21st, 2014, 4:06pm, Richard Russell wrote:
To be pedantic it's the Decimal Separator symbol, but your code is correct. Thanks for that.

Richard.


Oops... tongue, big mistake but it is corrected now.
Re: How to read regional setting from OS?
Post by FBack on Feb 23rd, 2014, 10:29am

Thank you very much PreciseTiming and Richard. The algorithm, which is attached, works perfectly.

The algorithm I need for my program that records data from the charger to the make correct format csv files for Microsoft Excel, depending on the regional settings of the operating system.