Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Program Help Needed!!

Featured Replies

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!!!

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.

  • Author

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

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.

  • Author

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 

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.