Every three month reminder

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Every three month reminder

12 Feb 2014, 11:30

Hi!

I find it quite hard doing scripts using time, days, months and years. I was looking for some script already made that could help me get a reminder the day before every three months period has passed. There are scripts that retrieves the first or last day of every month, but cant seem to find anything using longer interval. How to go about this? Looking for something where the interval is tweakable with variable passed to function.

Some functions which are not quite doing what im after:
Spoiler
Spoiler
just me
Posts: 9542
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Every three month reminder

12 Feb 2014, 12:03

Hi,

how do you define a 'three month period', respectively, how do you define a 'month'?
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Re: Every three month reminder

12 Feb 2014, 15:38

Greetings just me :)

After giving it some thought the LDOM function will do what im after. Im not sure if i complicate things more than necessary. Here is the script im playing with, which also answers your questions. However I cant get the associative array with keys to work though. What have i done wrong? It actually works with the disabled simpler array though. With it i get the last day of the month before next three months period begins. When that actual day occurs i should be abled to fire up a reminder.

Code: Select all

Months := {"February": ["02"]   ;for quarter March - May
     ,     "May": ["05"]        ;for quarter June - August
     ,     "August": ["08"]     ;for quarter September - November
	 ,     "November": ["11"] } ;for quarter December - February
;Months := ["02", "05", "08", "11"]
FormatTime, Year, % Tomorrow, yyyy ; Which year is it tomorrow
for Key, Month in Months {
   msgbox % Key
   msgbox % Month
   Result := LDOM(Year . Month)
   MsgBox % Result
}
return

LDOM(TimeStr="") {
  If TimeStr=
     TimeStr = %A_Now%
  StringLeft Date,TimeStr,6 ; YearMonth
  Date1 = %Date%
  Date1+= 31,D              ; A day in next month
  StringLeft Date1,Date1,6  ; YearNextmonth
  Date1-= %Date%,D          ; Difference in days
  Return Date1
}
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Every three month reminder

12 Feb 2014, 16:26

Enclosing values in [] is making them arrays. Consider the difference:

Code: Select all

Months := {"February": ["02", "09", "04"]
     ,     "May": ["05"]
     ,     "August": ["08"]
     ,     "November": ["11"] }
	 
for Key1, Val1 in Months {
	for Key2, Val2 in Val1 {
		msgbox % "Message1:`n " Key1 "`n" Key2 "`n" Val2
	}
}

; Note, "Months" doesn't need to be on multiple lines, it's just a style choice for readability.
; this is the same:
; Months := {"February": "02", "May": "05", "August": "08", "November": "11"}
Months := {"February": "02"
     ,     "May": "05"
     ,     "August": "08"
     ,     "November": "11" }

for Key, Month in Months {
   msgbox % "Message2:`n" Key "`n" Month
}
See Associative_Arrays
zcooler
Posts: 455
Joined: 11 Jan 2014, 04:59

Re: Every three month reminder

12 Feb 2014, 16:53

Aha, that explains it. Thanks again kon for helping me. I think I get this now.
Now my parkingreminder script is complete :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: hammer32, mikeyww and 73 guests