Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timeformat Question
#1
Hello QM Forum,

I'm working on building out a simple calendar app that auto populates the days of the week based on the current month and the day. It's a very basic dialog with buttons as placeholders for the calendar. There are 35 in total; 7 columns and 5 rows. The idea I had initially was to find out the current day of the week and do some math to count forwards and/or backwards to fill in the rest of the dates in the proper order. While I think this can work with some finessing, I was curious if there is a more simple way to determine the initial starting day of the week for the 1st of the current month.

For example, November 1st is on Thursday, December 1st is on Saturday, etc. I know this can be done manually, but I'd like the option for the days to auto populate for future use.
#2
function below will get the first day of the current month and the weekday and output it as a string

Function FirstDayOfMonthAndWeekday 
Code:
Copy      Help
SYSTEMTIME st
GetSystemTime(&st)
DateTime dt1
sub.GetFirstDayOfaMonth(st.wYear st.wMonth dt1)
out dt1.ToStrFormat("{dddd} {D}")

#sub GetFirstDayOfaMonth
function year month DateTime&dt
int day=1
dt.FromParts(year month day)
ret
#3
Wow Kevin this is exactly what I was looking for. Definitely much cleaner than what I was trying too.

This works great but I was wondering if you could write a quick explanation of this portion of code?

Code:
Copy      Help
#sub GetFirstDayOfaMonth
function year month DateTime&dt
int day=1
dt.FromParts(year month day)
ret

I get the gist of it but I've never seen the #sub tag used before.
#4
the sub tag is for sub function. 


From QM Help

Sub-functions are user-defined functions that are embedded in text of their parent QM item (macro etc). Unlike usual QM user-defined functions, they aren't separate QM items that you could manage in the list of macros. Sub-functions can be used in macros, functions, member functions, menus, toolbars and autotexts.

To learn more put the cursor on #sub in the qm editor and press F1.
or read here
http://www.quickmacros.com/help/Language...R_SUB.html
#5
Oh I see now. So kind of similar to how you can call JavaScript functions inside the HTML file. Thanks for the information Kevin!


Forum Jump:


Users browsing this thread: 1 Guest(s)