Jump to content

Program Help Needed!!


Recommended Posts

Posted

So I have a program that sends an email.  The email contains a variable.  Its all working fine.

But here is the issue.  The variable counts years.

So for now the email says something like.    Its the 3 year now. 

Well of course I want it to say 3rd.

But then you have 1rst, 2nd, and the rest end in th.

So is there an easy way to do that without a program that says if its 1, 21, 31, 41 then use ST. If 2, 22, 33, 44 then use nd.

and so on.

This may be easier than I think,.  My mind is just all over the place thinking about this.

thanks in adavnce!!!

Posted

One way would be to create a special notification for anything that isn't "th". But then you'd need 3 more I guess: 1 that has variable + "st", a second that has variable + "nd", and a third with variable + "rd", all in addition to the standard one that has "th". I hate the English language sometimes.

Posted

That’s what I did for now.  The problem is I have to go all the way up to 100 so it means a lot of ifs.  
 

I was thinking if someone could help me is a program to split the number and check the right most digit    so for instance, 43 would be split and a new variable would be  3

So now you could check just the new variable.  
 

But then there’s English problems. For example 13 and in a three, but it’s 13th. Not 13 RD.     
 

This isn’t easy… Lol

Posted

Please forgive me for not directly answering your question, but as an alternative, have you considered changing your english to simpllfy it? "It is year 3 now" works for all numbers.

  • Like 1
Posted

My example was just an example, and I have actually multiple reasons I need this
 

But think of an anniversary.  Even if you said this is your third year you still have to say RD
 

You wouldn’t say it is your three of your work here    it just doesn’t sound right.   
 

but I appreciate the suggestion and any other suggestions people send 

Posted (edited)

Use this as a template for the logic. It's in python, but it's just math so it's all the same:

def foo(myDate):
    date_suffix = ["th", "st", "nd", "rd"]

    if myDate % 10 in [1, 2, 3] and myDate not in [11, 12, 13]:
        return date_suffix[myDate % 10]
    else:
        return date_suffix[0]

ISY also has the (%) which gives you the remainder after the divide. So if you have two variables, test and test2, and test = 43, and in your program you put:

test2 = test

test2 % 10

then you will see that test2 will equal 3.

------------------------------------------

The below doesn't account for 0 or over 99:

I'm not sure prog1 is going to get triggered, you'll have to test all of this and report back.

prog1
if test = 11
or test = 12
or test = 13
then send th email
else
test2 = test
test2 % 10
run prog2 (if)

prog2 (disabled)
if test2 = 1
then send st email
else run prog3 (if)

prog3 (disabled)
if test2 = 2
then send nd email
else run prog4 (if)

prog4 (disabled)
if test2 = 3
then send rd email
else send th email

Edited by gregkinney
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...