Logic Machine Forum
Namedays, Birthdays reminder script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Namedays, Birthdays reminder script (/showthread.php?tid=2248)



Namedays, Birthdays reminder script - AlexLV - 22.09.2019

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


RE: Namedays, Birthdays reminder script - admin - 26.09.2019

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 ]



RE: Namedays, Birthdays reminder script - AlexLV - 26.09.2019

admin,

BIG Thanks!

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

BR,

Alex