Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
1st, 2nd, 3rd, 4th, 5th ... nth
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00446283
Message ID:
00446389
Vues:
8
>parameter x
>return iif(between(x, 11, 13), "th", iif(right(str(X),1) = "1", "st", iif(right(str(X),1) = "2", "nd", iif(right(str(X),1) = "3", "rd", "th"))))
Ken, I spotted your one-liner and felt compelled to match it ;-)
FOR iNumber = 1 TO 31
   ? "  " + TRANSFORM( iNumber ) + fOrdinal( iNumber )
NEXT iNumber

****************************
FUNCTION fOrdinal( iNumber )
****************************
   RETURN IIF( NOT BETWEEN( iNumber, 11, 13 ) AND BETWEEN( MOD(iNumber,10), 1, 3 ) ;
             , SUBSTR( "stndrd", (MOD(iNumber,10) * 2) -1, 2 ) ;
             , "th" )
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform