help with understanding why script dont give disired outcome
Douglas Mackay
DouglasMackay at blueyonder.co.uk
Sun Feb 1 16:55:20 EST 2004
here is part of the script I am working with :
on mouseUp
global Gbox
ask "Date of Birth? (eg. 23/9/1987)"
put it into firstDate
ask "Date of Assessment? (eg. 18/3/2001)"
put it into secondDate
put whichage (firstDate, secondDate) into dateholder
if Gbox = 1
then put "year" into field "nameYear"
else
put "years" into field "nameYear"
end if
put Gbox into field "year2"
if item 2 of dateholder = 1
then put "month" into field "nameMonth"
else
put "months" into field "nameMonth"
end if
put item 2 of dateholder into field "month"
if item 3 of dateholder = 1
then put "day" into field "nameDay"
else
put "days" into field "nameDay"
end if
put item 3 of dateholder into field "day"
end mouseUp
function whichage fromwhich,towhich
global Gbox
set the centuryCutoff to 35
set useSystemDate to true
if param(1) = "" then exit to top
put param(1) into startdate
put param(2) into enddate
set the itemDelimiter to "/"
put item 3 of startdate into GsYear
put item 3 of enddate into GeYear
set the itemDelimiter to comma
convert startdate to dateitems
convert enddate to dateitems
put item 3 of enddate into bbmsg
put (item 3 of enddate - item 3 of startdate) into diffjour
if diffjour < 0 then
add "1" to item 2 of startdate
get item 2 of enddate
if (it is in "1,3,5,7,8,10") or (it= "12") then put "31" into correction
else if (it is in "4,6,9,11") then put "30" into correction
else if item 1 of enddate mod 4 = 0 then put "29" into correction
else put "28" into correction
add correction to item 3 of enddate
put (item 3 of enddate - item 3 of startdate) into diffjour
end if
put (item 2 of enddate - item 2 of startdate) into diffmois
if diffmois < 0 then
add "1" to item 1 of startdate
put (item 2 of enddate) + 12 into item 2 of enddate
put (item 2 of enddate - item 2 of startdate) into diffmois
add "1" to GsYear
the line in bold type will not work when giving start and enddates 1961 , and for example todays date .having looked in the debugger convert startdate to dateitems
and convert enddate to dateitems
only converts the enddate to dateitems
can anyone explain why this happens please to me ?
Douglas
More information about the use-livecode
mailing list