Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calendar
Message
From
27/08/2008 02:59:33
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
25/08/2008 08:27:02
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01341448
Message ID:
01342101
Views:
13
Hi Hilmar, Hi Mohamed,

PDMFJI.
You could use API function GetLocaleInfo.
FUNCTION My_CMONTH
 LPARAMETERS;
  tvDate

 LOCAL;
  lnLang AS INTEGER

   lnLang = SUBLANG_ENGLISH_UK   && 0x0800;  A Language as defined in foxpro.h
 RETURN LocalMonthName(MONTH(tvDate),.T.,lnLang)
ENDFUNC &&My_CMONTH

FUNCTION LocalMonthName						&&Bestimmt per API Ruf Monatsnamen in beliebiger Sprache
 LPARAMETERS;
  tnMonth,;
  tvAbbrev,;
  tnLang

 LOCAL;
  lcBuffer AS CHARACTER,;
  lnChars  AS INTEGER

 IF (!VARTYPE(tnMonth)=T_Numeric) OR !BETWEEN(tnMonth,1,12) THEN
  ERROR 11
 ENDIF &&(!VARTYPE(tnMonth)=T_Numeric ...

 tvAbbrev = IIF(EMPTY(tvAbbrev),0x37,0x43)

*System default if nothing is given 
tnLang = IIF(VARTYPE(tnLang)=T_Numeric,tnLang,0)

 DECLARE LONG GetLocaleInfo IN Win32API ;
  LONG Locale, LONG LCType, STRING @ lpLCData, LONG cchData

 lcBuffer = REPLICATE(CHR(0), 16)
 lnChars  = GetLocaleInfo(tnLang, tvAbbrev+tnMonth,@lcBuffer,16)
 RETURN LEFT(lcBuffer,lnChars-1)
ENDFUNC &&LocalMonthName
I prefer to have global define
#DEFINE CMONTH My_CMonth
this will redefine all CMONTH ad once. But this depends on the design.

You can do the same with CDOW. Just change the line with tvAbbrev to:

Agnes
 tvAbbrev = IIF(EMPTY(tvAbbrev),0x29,0x30)
>Mohammed, I avoid using cmonth(), because the result is dependent on the runtime version installed. Specifically, cmonth() gives me the months in English, and I want them in Spanish. So, I create a personalized cMonth function, which I call MyCMonth(). Something like this:
>
>
>lparameters tnMonth
>
>* The following allows passing a date, or a number, as a parameter.
>if type("tnMonth") = "D"
>  tnMonth = month(tnMonth)
>endif
>
>do case
>case tnMonth = 1
>  return "January"
>case tnMonth = 2
>  return "February"
>...
>otherwise && Some wrong input, perhaps?
>  return "???"
>endcase
>
>
>Of course, my own version of the function returns the months in Spanish - I left them in English here, for clarity.
>
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform