[xmpie-users] Adding the st, nd, rd, or th as number is entered to online doc

114 views
Skip to first unread message

Debbie

unread,
Apr 28, 2010, 1:23:46 PM4/28/10
to XMPie Interest Group
On our storefront, we have a postcard where the user can enter the
number and we need the corresponding text to pull in, ie: 1st, 2nd,
3rd, 4th....25th....46th....99th. Or, user enters "10" and "th" is
added for "10th".

Anyone have a suggestion on the logic for this? Qlingo exist for this?

--
You received this message because you are subscribed to the Google Groups "XMPie Interest Group" group.
To post to this group, send email to xmpie...@googlegroups.com.
To unsubscribe from this group, send email to xmpie-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xmpie-users?hl=en.

Message has been deleted

Bill

unread,
Apr 28, 2010, 3:47:43 PM4/28/10
to XMPie Interest Group
Knowing that English is not my mother tong, something like the
following should work:

if ( ( ( @{yournumber} % 10 ) = 1 ) and ( @{yournumber} <> 11 ) )
{
AsString(@{yournumber}) & "st"
}
else
{
if ( ( ( @{yournumber} % 10 ) = 2 ) and ( @{yournumber} <> 12 ) )
{
AsString(@{yournumber}) & "nd"
}
else
{
if ( ( ( @{yournumber} % 10 ) = 3 ) and ( @{yournumber} <>
13 ) )
{
AsString(@{yournumber}) & "rd"
}
else
{
AsString(@{yournumber}) & "th"
}
}
}

A bit more difficult, if you numbers go over 110...

Debbie

unread,
Apr 28, 2010, 6:27:04 PM4/28/10
to XMPie Interest Group
Thank you, Bill! This got me 3/4 of the way there - very much
appreciated.

ed kotnik

unread,
Apr 28, 2010, 7:03:10 PM4/28/10
to XMPie Interest Group
This should do the trick:

Make a variable called "yournumber" and set it to a Campaign Dial.

Then make an ADOR and place this into the expression window.

@{yournumber} &

switch (@{yournumber})
{
case 1:"st"
case 2:"nd"
case 3:"rd"
case 21:"st"
case 22:"nd"
case 23:"rd"
case 31:"st"
default:"th"
}

Hope it works.

ed kotnik

unread,
Apr 28, 2010, 7:22:08 PM4/28/10
to XMPie Interest Group
My last post only trapped dates. Sorry about that.

These things called "ordinals" and there are many javascript and
vbscript functions out there. You could most likely do the same thing
for QLingo. Bill's post forgot to trap 111, 211, 311, etc...

Here's a sample of a javascript sample I found.

Number.prototype.ordinal = function () {
return this + (
(this % 10 == 1 && this % 100 != 11) ? 'st' :
(this % 10 == 2 && this % 100 != 12) ? 'nd' :
(this % 10 == 3 && this % 100 != 13) ? 'rd' : 'th'
);
}


On Apr 28, 10:23 am, Debbie <debbiesp...@gmail.com> wrote:

Bill

unread,
Apr 29, 2010, 2:38:06 AM4/29/10
to XMPie Interest Group
I voluntarily did not take the big values into account, as Debbie
stopped her sample values at 99.
I wanted to provide a code as simple as possible, in order to avoid
any confusion.
Here is a formula, which can certainly be applied, whatever the limit:

if ( ( ( @{yournumber} % 10 ) = 1 ) and ( ( @{yournumber} % 100 ) <>
11 ) )
{
AsString(@{yournumber}) & "st"
}
else
{
if ( ( ( @{yournumber} % 10 ) = 2 ) and ( ( @{yournumber} % 100 )
<> 12 ) )
{
AsString(@{yournumber}) & "nd"
}
else
{
if ( ( ( @{yournumber} % 10 ) = 3 ) and ( ( @{yournumber} %
100 ) <> 13 ) )
{
AsString(@{yournumber}) & "rd"
}
else
{
AsString(@{yournumber}) & "th"
}
}
}

On 29 avr, 01:22, ed kotnik <ekot...@121services.com> wrote:
> Bill's post forgot to trap 111, 211, 311, etc...
>

Reply all
Reply to author
Forward
0 new messages