Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Number suffixes
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00389642
Message ID:
00389716
Vues:
14
>Is there a function that returns the suffix of a number? Like for 1 it would return 'st' for 1st, and for 2 it would return 'nd', 3 returns 'rd' and '300' would return 'th' etc... Just wondering if one existed within the visual studio environment before i have to write my own.
>
>Thanks in advance - Eric

Eric,

function getsuffix
lparameters lnnumber

local llabort
local lcSuffix
local lcDigit
local lcSpecial

llabort=!(type('lnnumber')='N')
STORE '' TO lcSuffix,lcSpecial

if ! llabort
lnnumber = int(abs(lnnumber))
lcDigit=right(alltrim(str(lnNumber)),1)
lcSpecial=right(alltrim(str(lnNumber)),2)
do case
case INLIST(lcSpecial,'11','12','13')
lcSuffix='TH'
otherwise
lcSuffix=IIF(lcDigit$'0456789','TH',lcSuffix)
lcSuffix=IIF(lcDigit='1','ST',lcSuffix)
lcSuffix=IIF(lcDigit='2','ND',lcSuffix)
lcSuffix=IIF(lcDigit='3','RD',lcSuffix)
endcase
endif

RETURN lcSuffix
endfunc

Jon
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform