Article ID 1075
Article Title EXAMPLE: Retrieve weekday names in current language setting in Windows
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=1075
KBase Category Visual DataFlex
Date Created 03/30/2000
Last Edit Date 03/30/2000


Article Text
In Windows the name of each day of the week for many supported languages is stored in a datablock called the Windows Locale. The following is source code which was used to test and create retrieval functions for this information.

//CODE:
Use Windows
Use Dll
Use Dferror

Define Locale_User_Default For |CI$0400

External_Function GetLocaleInfo "GetLocaleInfoA" Kernel32.dll ;
   Dword LCID Dword LCTYPE Pointer lpLCDATA Integer cchData Returns Integer

Define LOCALE_SDAYNAME1       For |CI$0000002A // long name for Monday
Define LOCALE_SDAYNAME2       For |CI$0000002B // long name for Tuesday
Define LOCALE_SDAYNAME3       For |CI$0000002C // long name for Wednesday
Define LOCALE_SDAYNAME4       For |CI$0000002D // long name for Thursday
Define LOCALE_SDAYNAME5       For |CI$0000002E // long name for Friday
Define LOCALE_SDAYNAME6       For |CI$0000002F // long name for Saturday
Define LOCALE_SDAYNAME7       For |CI$00000030 // long name for Sunday
Define LOCALE_SABBREVDAYNAME1 For |CI$00000031 // abbreviated name for
Monday
Define LOCALE_SABBREVDAYNAME2 For |CI$00000032 // abbreviated name for
Tuesday
Define LOCALE_SABBREVDAYNAME3 For |CI$00000033 // abbreviated name for
Wednesday
Define LOCALE_SABBREVDAYNAME4 For |CI$00000034 // abbreviated name for
Thursday
Define LOCALE_SABBREVDAYNAME5 For |CI$00000035 // abbreviated name for
Friday
Define LOCALE_SABBREVDAYNAME6 For |CI$00000036 // abbreviated name for
Saturday
Define LOCALE_SABBREVDAYNAME7 For |CI$00000037 // abbreviated name for
Sunday

Function DayName Global Integer iDay Returns String
   Local String sDayName
   Local Pointer lpsDayName
   Local Integer iVoid

   ZeroString 20 To sDayName
   GetAddress Of sDayName To lpsDayName
   Moveint (GetLocaleInfo (LOCALE_USER_DEFAULT, iDay, lpsDayName, 20)) To
iVoid

   Function_Return (CString (sDayName))
End_Function // DayName

Procedure DoShowWeekDays
   Local Integer iDay

   For iDay From LOCALE_SDAYNAME1 To LOCALE_SDAYNAME7
      Showln "Day: " (iDay - LOCALE_SDAYNAME1 + 1) " " (DayName (iDay))
   Loop

   For iDay From LOCALE_SABBREVDAYNAME1 To LOCALE_SABBREVDAYNAME7
      Showln "Day: " (iDay - LOCALE_SABBREVDAYNAME1 + 1) " " (DayName
(iDay))
   Loop
End_Procedure // DoShowWeekDays

Send DoShowWeekDays
Send Info_Box "Program completed, results in Output Window"
//CODE_END




Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2024 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.