1. wxEuphoria Calendar Control: Getting Count of Days in Month

I created the following, but it doesn't work! Helllp!

--/topic wxCalendarCtrl
--/func get_daysinmonth( atom cal )
--
--Returns the number of days in the currently selected month.
global function get_daysinmonth( atom cal )
	return cpp:call_member( wxDateTime_GetNumberOfDays_1, cal, {})
end function


I tried also the wxDateTime_GetNumberOfDays, but apparently I don't know
how to form the parameters, but I'm sure that's the one I want to call. :/

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » topic index » view message » categorize

2. Re: wxEuphoria Calendar Control: Getting Count of Days in Month

cklester wrote:
> 
> I created the following, but it doesn't work! Helllp!
> 
> }}}
<eucode>
> --/topic wxCalendarCtrl
> --/func get_daysinmonth( atom cal )
> --
> --Returns the number of days in the currently selected month.
> global function get_daysinmonth( atom cal )
> 	return cpp:call_member( wxDateTime_GetNumberOfDays_1, cal, {})
> end function
> </eucode>
{{{

> 
> I tried also the wxDateTime_GetNumberOfDays, but apparently I don't know
> how to form the parameters, but I'm sure that's the one I want to call. :/

wxDateTime_GetNumberOfDays_1 is actually a static function, which means 
that you don't pass the object, so you just use cdecl to call it.  Also,
you appear to be passing a wxCalendarCtrl when it would be expecting a 
wxDateTime.  Try this code instead:

--/topic wxDateTime
--/func get_days_in_month( atom dt )
--
--Returns the number of days in the specified month and year.
global function get_days_in_month( integer month, integer year )
  return cpp:call_cdecl( wxDateTime_GetNumberOfDays, { month-1, year, 0 })
end function

--/topic wxCalendarCtrl
--/func get_cal_days_in_month( atom cal )
--
--Returns the number of days in the currently selected month.
global function get_cal_days_in_month( atom cal )
	sequence d

	d = read_datetime( get_date_time( cal ) )

	return get_days_in_month( d[Dt_month], d[Dt_year] )
end function


Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. Re: wxEuphoria Calendar Control: Getting Count of Days in Month

Matt Lewis wrote:
 
> --/topic wxCalendarCtrl
> --/func get_cal_days_in_month( atom cal )
> --
> --Returns the number of days in the currently selected month.
> global function get_cal_days_in_month( atom cal )
> sequence d
> 	d = read_datetime( get_date_time( cal ) )
>       return get_days_in_month( d[Dt_month], d[Dt_year] )
> end function

With one minor change, it works perfectly.

Instead of

     d = read_datetime( get_date_time( cal ) )

which causes an error for me, you can just use

     d = get_date( cal )

which works fine!

Thanks, Matt! (Now how about those other questions? :) )

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu