Announcement

Collapse
No announcement yet.

System Locale for weights and measures?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anthony Watson
    replied
    Egbert,

    Thanks for the sample, I think that will work fine...

    Anthony

    Leave a comment:


  • Jeff Blakeney
    replied
    When it comes down to it, I think the US is probably the last country still using imperial units rather than metric. It was probably over 15 years ago that I read somewhere that there were only three countries left in the world that weren't using metric so the other two small countries may have changed by now. I know there is still some mixing of units in places like here in Canada, the UK and elsewhere but officially we are metric countries.

    Leave a comment:


  • Egbert Zijlema
    replied
    code sample

    Here's a sample (tested on XP)

    Code:
    #COMPILE EXE
    #DIM ALL
    
    %LOCALE_USER_DEFAULT     = &H0400&
    %LOCALE_SYSTEM_DEFAULT   = &H0800&
    %LOCALE_IMEASURE         = &H0000000D   ' 0 = metric, 1 = US
    
    DECLARE FUNCTION GetLocaleInfo LIB "KERNEL32.DLL" ALIAS "GetLocaleInfoA" (BYVAL dwLocale AS DWORD, BYVAL LCType AS LONG, lpLCData AS ASCIIZ, BYVAL cchData AS LONG) AS LONG
    
    FUNCTION PBMAIN () AS LONG
      LOCAL szMeasures AS ASCIIZ * 2, iMeasures AS LONG, sOutput AS STRING
      GetLocaleInfo %LOCALE_USER_DEFAULT, %LOCALE_IMEASURE, szMeasures, SIZEOF(szMeasures)
      iMeasures = VAL(szMeasures)
      SELECT CASE AS LONG iMeasures
        CASE 0
          sOutput = "Found: metric system"
        CASE 1
          sOutput = "Found: American system"
      END SELECT
      MSGBOX sOutput, 64, " User's metric system"
    END FUNCTION

    Leave a comment:


  • Eric Pearson
    replied
    I think the closest you'll come is LOCALE_IMEASURE, which specifies metric units vs. US units.

    -- Eric

    Leave a comment:


  • Anthony Watson
    started a topic System Locale for weights and measures?

    System Locale for weights and measures?

    I know there are system functions for getting the date and time in a format that is unique to the users locale (i.e. GetDateFormat).

    Does anyone know if there is a way to determine programatically what volume and weight measurement systems are typical in the users locale?

    For example, I may measure liquids in gallons, where someone in another country may measure liquid in liters.

    Or, I may measure distances in miles, where other countries may measure distances in kilometers.

    Ideally, I'd like to query the Windows API to determine what measurements are in use so my program can make whatever conversions are needed automatically.

    Thanks,

    Anthony
Working...
X