global gSessionA, gBedTime, gWakeTime, gClockBehavior on closeStack save this stack pass closeStack end closeStack on OpenStack --set the decorations of this stack to empty restoreSavedDiffs resetTime end OpenStack on restoreSavedDiffs put the uSavedDiffs of this stack into tDiffs repeat with x = 1 to the number of lines in tDiffs put line x of tDiffs into thisLine -- GENERATE FLD NAME put "Name" & x into tNameFldName put "Diff" & x into tDiffFldName -- PLACE NAME AND DIFFS INTO FLDS set the itemdel to "|" put item 1 of thisLine into fld tNameFldName put item 2 of thisLine into fld tDiffFldName end repeat -- TRIGGER THE FUNCTION TO SHOW CORRECT TIMES resetTime end restoreSavedDiffs on saveDiffs -- GET TOTAL PEOPLE put 8 into tTotalPersons -- REPEAT FOR EACH PERSON repeat with x = 1 to tTotalPersons -- DYNAMICALLY GEN FLD NAMES put "Name" & x into tNameFld put "Diff" & x into tDiffFld -- CHECK FOR THE DELIMITER IN THE CONTENTS if fld tNameFld contains "|" OR fld tDiffFld contains "|" then answer "ERROR: The diff or name contains a |, this will cause problems in the future" end if -- put fld tNameFld & "|" & fld tDiffFld & lf after tSave end repeat -- SAVE THE DATA AS A CUSTOME PROP set the uSavedDiffs of this stack to tSave -- Save the stack if not(the environment is "development") then save this stack end saveDiffs on CurrentTimeBtnPressed put "TRUE" into gClockBehavior resetTime end CurrentTimeBtnPressed on resetTime set the twelveHourTime to "FALSE" set the itemdel to colon put the time into tTime put (((item 1 of tTime) * 60)+ item 2 of tTime) into tTotalMins set the thumbposition of scrollbar "Scrollbar" to tTotalMins set the itemdel to comma set the twelveHourTime to "TRUE" put the time into fld "my time" end resetTime function clockTimeToMins pClockTime --This function assumes the parameter is a 12 hour time with and AM or PM -- For example "12:35 PM" -- It assumes 8 total chars including the space -- No validation of parameter yet. put pClockTime into tClockTime if tClockTime contains "PM" then put "true" into tPM put char 1 to -3 of tClockTime into tClockTime -- remove the space and AM/PM set the itemdel to colon if item 1 of tClockTime is 12 then put 00 into item 1 of tClockTime --if item 2 of tClockTime is 12 then put 00 into item 2 of tClockTime put (((item 1 of tClockTime) * 60)+ item 2 of tClockTime) into tTotalMins if tPM is "true" then put (tTotalMins + 720) into tTotalMins set the itemdel to comma return tTotalMins end clockTimeToMins function fixRangeTotalMins pTotalMins -- CLeans up the TotalMins type of variables so that they are neatly within a rang of 1-1440 put pTotalMins into tTotalMins if tTotalMins < 0 then put (1440 + tTotalMins) into tTotalMins if tTotalMins >= 1440 then put (tTotalMins - 1440 ) into tTotalMins return tTotalMins end fixRangeTotalMins function minsToClockTime pTotalMins put pTotalMins into tTotalMins put fixRangeTotalMins(tTotalMins) into tTotalMins set the numberFormat to "##.##" --ASSUME CASE IS AM AND MAKE SEPERATE MODIFICATION FOR PM CASE -- PM CASE BOOLEAN AND ADJUSTMENST if tTotalMins > 719 then put "true" into tPM put tTotalMins-720 into tTotalMins end if --Convert Mins to HR:MIN format put (the round of (tTotalMins/60)) into tRoundedHrs if tTotalMins/60 < tRoundedHrs then put (tRoundedHrs - 1) into tRoundedHrs put ((tTotalMins/60) - tRoundedHrs)*60 into tMins if tRoundedHrs is 00 then put 12 into tRoundedHrs put (tRoundedHrs & ":" & tMins && "AM") into tResponse if tPM then replace "AM" with "PM" in tResponse return tResponse end minsToClockTime on addBehaviorsToFlds repeat with y = 1 to 2 if y is "1" then put "Diff" into tFldPrefix if y is "2" then put "Name" into tFldPrefix repeat with x = 1 to 8 put tFldPrefix & x into tFldName set the behavior of fld tFldName to the long id of btn "BehaviorS" of cd "Resources" end repeat end repeat -- TWO MORE set the behavior of fld "BedTime" to the long id of btn "BehaviorS" of cd "Resources" set the behavior of fld "WakeTime" to the long id of btn "BehaviorS" of cd "Resources" end addBehaviorsToFlds ON saveSettings --SAVES THE BED TIME AND WAKE TIME INTO GLOBALS put fld "BedTime" into gBedTime put fld "WakeTime" into gWakeTime end saveSettings on mainScrollbarDrag pNewPosition --answer "trig" --set globa -- the scroll bar goes from 0 to the number of minutes in a day put minsToClockTime(pNewPosition) into tMyTime put tMyTime into fld "ScrollTime" put tMyTime into fld "ScrollTimeShadow" put tMyTime into fld "my time" showOtherTimes end mainScrollbarDrag on showOtherTimes put fld ScrollTime into tWorkingClockTime put clockTimeToMins(tWorkingClockTime) into tWorkingTime repeat with x = 1 to 8 put empty into tTimeDiff put ("Diff" & x) into tDiffFldName put fld tDiffFldName into tTimeDiff --FLD needs validation put tTimeDiff * 60 into tTimeDiff put ("time" & x) into tTimeFldName put tWorkingtime + tTimeDiff into tTotalMins put fixRangeTotalMins(tTotalMins) into tTotalMins saveSettings if tTotalMins > (720 + (gBedTime * 60)) or tTotalMins < (gWakeTime * 60) then set the backcolor of fld tTimeFldName to "#e05862" else set the backcolor of fld tTimeFldName to "#acd63d" end if put minsToClockTime(tTotalMins) into tClockTime put tClockTime into fld tTimeFldName end repeat end showOtherTimes // NEW STUFF -- GOALS // SECONDS SUPPORT // 24 HR TIME FORMAT SUPPORT command updateFriendsArray pUserTime /* tFriendsArray["FriendName"]["Time"] tFriendsArray["FriendName"]["WakeTime"] tFriendsArray["FriendName"]["BedTime"] tFriendsArray["FriendName"]["WorkStartTime"] tFriendsArray["FriendName"]["WorkEndTime"] */ -- GET THE TIME THAT THE --ASSUME end updateFriendsArray