Re: Ordinal Numbers (1st, 2nd, etc.)
Re: Ordinal Numbers (1st, 2nd, etc.)
- Subject: Re: Ordinal Numbers (1st, 2nd, etc.)
- From: Victor Yee <email@hidden>
- Date: Thu, 16 Aug 2001 21:54:12 -0400
On Thu, 16 Aug 2001 21:41:34 -0400, I wrote,
>
on ordinalNum(x)
>
set tempString to ("0" & x)
>
set teenFlag to (tempString's text item -2 is not "1")
>
set lastDigit to (tempString's last item)
>
if (teenFlag) and (lastDigit is "1") then
>
return ("" & x & "st")
>
else if (teenFlag) and (lastDigit is "2") then
>
return ("" & x & "nd")
>
else if (teenFlag) and (lastDigit is "3") then
>
return ("" & x & "rd")
>
else
>
return ("" & x & "th")
>
end if
>
end ordinalNum
Minor correction. For clarity, the "teenFlag" variable should be renamed to "notTeen".
Victor