Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
1st, 2nd, 3rd, 4th, 5th ... nth
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00446283
Message ID:
00446389
Views:
16
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform