This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Namedays, Birthdays reminder script
#1
Hi,
I just start created simple script for Name-days showing. It works, but realization I don/t like.. It just Scheduled script started every midnight:
Code:
--Namedays Script v.1

-- Set output address where Names will be showed
AddressOutput = '1/7/10'

Today = tonumber(string.format('%02d%02d', os.date("%d"), os.date("%m")))
-- Just today date converted in format ddmm and below comparison


if Today == 2209 then Nameday = "Maigurs, Mārica, Māris"
end
if Today == 2309 then Nameday = "Vanda, Veneranda, Venija"
end
if Today == 2409 then Nameday = "Agris, Agrita"
end
if Today == 2509 then Nameday = "Rauls, Rodrigo"
end
if Today == 2609 then Nameday = "Gundars, Knuts Kurts"
end
if Today == 2709 then Nameday = "Ādolfs, Ilgonis"
end
if Today == 2809 then Nameday = "Lana, Sergejs, Svetlana"
end
if Today == 2909 then Nameday = "Miģelis, Mihails, Miķelis, Miks, Mikus"
end
if Today == 3009 then Nameday = "Elma, Elna, Menarda"
end
if Today == 0110 then Nameday = "Lāsma, Zanda, Zandis"
end
if Today == 0210 then Nameday = "Ilma, Skaidris"
end
if Today == 0310 then Nameday = "Elza, Ilizana"
end

grp.write(AddressOutput, Nameday)

How better do this, I mean code? Some next improvements I plan to add - different countries names for Name-days and then select which countries Name-days show at visu and make reminders. Also could be used  for Birthdays or any celebration days..

So, any advises will be useful for me..

BR,

Alex
Reply
#2
You can create a table where keys are dates and values are names. This way you don't need so many if statements.
Code:
Dates = {
[2209] = "Maigurs, Mārica, Māris",
[2309] = "Vanda, Veneranda, Venija",
}
Nameday = Dates[ Today ]
Reply
#3
admin,

BIG Thanks!

This I need, but don't now how to solve.

BR,

Alex
Reply


Forum Jump: