Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
1st, 2nd, 3rd, 4th, 5th ... nth
Message
De
28/11/2000 13:00:13
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
 
À
28/11/2000 12:50:23
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00446283
Message ID:
00446295
Vues:
9
Hi Mike,
I call this Ending.PRG
*  Author............: Charlie Schreiner
*  Created...........: 12/20/94
PARAMETERS m.Number, m.Join	
LOCAL End, Digit
End = ''
ASSERT VARTYPE(m.Number) = "N" MESSAGE "You must pass a number to this function."
IF VARTYPE(m.Join) <> "L"
	Join = .T.
ENDIF
Digit = RIGHT(STR(INT(m.Number)),1)
DO CASE
CASE m.Digit = "1" AND NOT RIGHT(ALLTRIM(STR(INT(m.Number))),2) = "11"	&& Eleventh is 11th, not 11st.
	End = "st"
CASE m.Digit = "2" AND NOT RIGHT(ALLTRIM(STR(INT(m.Number))),2) = "12"	&& Twelve is 12th, not 12nd.
	End = "nd"
CASE m.Digit = "3" AND NOT RIGHT(ALLTRIM(STR(INT(m.Number))),2) = "13"	&& Thirteen is 13th, not 13rd.
	End = "rd"
OTHERWISE
	End = "th"
ENDCASE
RETURN IIF(m.Join,ALLTRIM(STR(m.Number) + m.End),m.End)
>Hi people!
>
>Anyone have a simple function to take a number and append the correct st, nd, rd or th? Its for a legal document "contract is made as of nth day of".
>
>Thanks
Charlie
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform