Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number to 1st, 2nd, 3rd or First, Second, Third
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00931326
Message ID:
00954208
Views:
31
Thanks Paul,
This is a great general purpose Ordinal Number generator function.
Terry :)

Note, the "fordinal" in the example should be changed to "ordinal"
in order for the example to work.
FOR x = 1 TO 1010
    ? TRANSFORM(x) + ordinal(x)
ENDFOR
>Just thought I'd pass along what I found that does the job for me. Thanx everyone.
>
>
>*!*****************************************************************
>*!*
>*!*    Function-> ORDINAL
>*!*
>*!*****************************************************************
>*!*	FOR x = 1 TO 1010
>*!*		? TRANSFORM(x) + ordinal(x)
>*!*	ENDFOR
>FUNCTION ordinal(inumber)
>	LOCAL ret_val
>	ret_val = IIF(!BETWEEN(inumber, 11, 13) AND BETWEEN(MOD(inumber,10), 1, 3), SUBSTR("stndrd", (MOD(inumber,10) * 2) -1, 2), "th")
>	RETURN ret_val
>ENDFUNC
>
>
>
>
>>I didn't want to reinvent the wheel so I thought I'd ask first. Does anyone have a utility to convert a number to a word that represents a position? For example.
>>
>>1 to "1st" (or "First")
>>2 to "2nd" (or "Second")
>>3 to "3rd" (or "Third")
>>4 to "4th" (or "Fourth")
>>5 to "5th" (or "Fifth") etc. etc.
>>
>>I've seen some other number to word conversions, but they weren't exactly what I was looking for.
>>
>>TIA
Previous
Reply
Map
View

Click here to load this message in the networking platform