%( tf1/tl1 = mm %)
%define;lex_month(xx)
%apply;nth%with;
/[(month)]0/[(month)]1/[(month)]2/[(month)]3/[(month)]4/[(month)]5/[(month)]6/[(month)]7/[(month)]8/[(month)]9/[(month)]10/[(month)]11%and;
xx%end;
%end;
%define;leg_month()
[(month)]0
[(month)]1
[(month)]2
[(month)]3
[(month)]4
[(month)]5
[(month)]6
[(month)]7
[(month)]8
[(month)]9
[(month)]10
[(month)]11
%end;
%define;months(z1,z2)
%reset_count;
%foreach;sorted_list_item;
%if;(prev_item.1 != item.1)
%apply;lex_month(item.1)
%apply;leg_month()
%end;
%if;(prev_item.1 != item.1 or prev_item.2 != item.2 or prev_item.3 != item.3)
%reset_count;%incr_count;
%expr(count - 1)
%if;(next_item.1 != item.1)
%end;
%end;
%end;
%end;
%define;anc_mm1(z1,z2,z3,z4)
%reset_count;
%empty_sorted_list;
%foreach;ancestor_level(l_v)
%if;(level > 1 and (evar.only != "on" or level = l_v))
%foreach;ancestor;
%if;(ancestor.same = "" and z1 != "" and z3 != "")
%incr_count;
%apply;add_in_sorted_list(z1,z2,z3,z4)
%end;
%end;
%end;
%end;
%end;
%define;anc_mm()
%if;(evar.tf2 = "1")
[year/month/day]1 [birth] = [year/month/day]1 [birth] [spouse/spouses]0 ?
%apply;anc_mm1("ancestor.birth_date.month","ancestor.spouse.sex","ancestor.spouse.birth_date.month","ancestor.spouse.index")
%elseif;(evar.tf2 = "2")
[year/month/day]1 [birth] = [year/month/day]1 [death] [spouse/spouses]0 ?
%apply;anc_mm1("ancestor.birth_date.month","ancestor.spouse.sex","ancestor.spouse.death_date.month","ancestor.spouse.index")
%elseif;(evar.tf2 = "3")
[year/month/day]1 [death] = [year/month/day]1 [death] [spouse/spouses]0 ?
%apply;anc_mm1("ancestor.death_date.month","ancestor.spouse.sex","ancestor.spouse.death_date.month","ancestor.spouse.index")
%elseif;(evar.tf2 = "4")
[year/month/day]1 [death] = [year/month/day]1 [birth] [spouse/spouses]0 ?
%apply;anc_mm1("ancestor.death_date.month","ancestor.spouse.sex","ancestor.spouse.birth_date.month","ancestor.spouse.index")
%else;
[year/month/day]1 [birth] = [year/month/day]1 [death] ?
%apply;anc_mm1("ancestor.birth_date.month","ancestor.sex","ancestor.death_date.month","ancestor.index")
%end;
[*total] = %count; [person/persons]1
%let;l_z1;
%if;(evar.tf2 = "1" or evar.tf2 = "2")%birth_symbol;
%elseif;(evar.tf2 = "3" or evar.tf2 = "4")%death_symbol;
%else;%birth_symbol;
%end;
%in;
%let;l_z2;
%if;(evar.tf2 = "1" or evar.tf2 = "4")x%birth_symbol;
%elseif;(evar.tf2 = "2" or evar.tf2 = "3")x%death_symbol;
%else;%death_symbol;
%end;
%in
%apply;months(l_z1,l_z2)
%end;
%define;anc_menu()
%let;l_url;%prefix;m=A;t=F;i=%index;;v=%l_v;;only=%evar.only;;maxv=%evar.maxv;%in;
%end;
%define;des_mm2(z1,z2,z3,z4,curlev,maxlev)
%if;(z1 != "" and z3 != "")
%incr_count;
%apply;add_in_sorted_list(z1,z2,z3,z4)
%end;
%foreach;family;
%if;(curlev < maxlev and family.desc_level = curlev)
%family.set_infinite_desc_level;
%if;(has_children)
%foreach;child;
%apply;des_mm2("z1","z2","z3","z4",curlev+1,maxlev)
%end;
%end;
%end;
%end;
%end;
%define;des_mm1(z1,z2,z3,z4,curlev,maxlev)
%foreach;family;
%if;(curlev < maxlev and family.desc_level = curlev)
%family.set_infinite_desc_level;
%if;(z1 != "" and z3 != "")
%incr_count;
%apply;add_in_sorted_list(z1,z2,z3,z4)
%end;
%if;(has_children)
%foreach;child;
%apply;des_mm1("z1","z2","z3","z4",curlev+1,maxlev)
%end;
%end;
%end;
%end;
%end;
%define;des_mm()
%reset_count;%reset_desc_level;%empty_sorted_list;
%if;(evar.tl2 = "1")
[year/month/day]1 [birth] = [year/month/day]1 [birth] [spouse/spouses]0 ?
%apply;des_mm1("birth_date.month","spouse.sex","spouse.birth_date.month","spouse.index",0,l_v)
%elseif;(evar.tl2 = "2")
[year/month/day]1 [birth] = [year/month/day]1 [death] [spouse/spouses]0 ?
%apply;des_mm1("birth_date.month","spouse.sex","spouse.death_date.month","spouse.index",0,l_v)
%elseif;(evar.tl2 = "3")
[year/month/day]1 [death] = [year/month/day]1 [death] [spouse/spouses]0 ?
%apply;des_mm1("death_date.month","spouse.sex","spouse.death_date.month","spouse.index",0,l_v)
%elseif;(evar.tl2 = "4")
[year/month/day]1 [death] = [year/month/day]1 [birth] [spouse/spouses]0 ?
%apply;des_mm1("death_date.month","spouse.sex","spouse.birth_date.month","spouse.index",0,l_v)
%else;
[year/month/day]1 [birth] = [year/month/day]1 [death] ?
%apply;des_mm2("birth_date.month","sex","death_date.month","index",0,l_v)
%end;
[*total] = %count; [person/persons]1
%let;l_z1;
%if;(evar.tl2 = "1" or evar.tl2 = "2")%birth_symbol;
%elseif;(evar.tl2 = "3" or evar.tl2 = "4")%death_symbol;
%else;%birth_symbol;
%end;
%in;
%let;l_z2;
%if;(evar.tl2 = "1" or evar.tl2 = "4")x%birth_symbol;
%elseif;(evar.tl2 = "2" or evar.tl2 = "3")x%death_symbol;
%else;%death_symbol;
%end;
%in
%apply;months(l_z1,l_z2)
%end;
%define;des_menu()
%let;l_url;%prefix;m=D;t=L;i=%index;;v=%l_v;;maxv=%evar.maxv;%in;
%end;
%( main %)
%let;l_max_width;180%in;
%apply;togen()
%if;(evar.m = "A")
%apply;anc_mm()
%apply;anc_menu()
%else;
%apply;des_mm()
%apply;des_menu()
%end;