-- background: 2611 from stack: in -- bmap block id: 6615 -- flags: 0000 -- background id: 0 -- name: Scheduler ----- HyperTalk script ----- on newStack extend end newStack on extend PLAY BOING put "SEND THE FEE, AND YOU'LL BE ALLOWED MORE MONTHS" end extend function getStartDate -- end of stack this month, whichever is newer put (field "Month") && "1," && (field "Year") into it if length(it) < 11 then put the date into it else convert it to seconds if field 16 is not empty then add 60*60*24*32 to it --add 32 days for next month if this month has dates end if put startOfMonth(it) into it --so we can compare put the date into thisMonth put startOfMonth(thisMonth) into thisMonth --both at week starts in seconds if thisMonth < 2587766400 then answer "Set the Control Panel to today's date" with "OK" return "Cancel" end if if it >= thisMonth then return it --calendar already beyond today convert it to short date convert thisMonth to short date answer "Start from which date?" with it or thisMonth or "Cancel" if it is "Cancel" then return it convert it to seconds return it end getStartDate function startOfMonth aDate -- the seconds of Monday before the 1st put 60*60*24 into OneDay --seconds in a day put aDate into it convert it to long date put 1 into word 2 of item 2 of it --first of month convert it to seconds convert it to long date repeat while item 1 of it <> "Sunday" convert it to seconds subtract OneDay from it --look for previous Sunday convert it to long date end repeat convert it to seconds return it end startOfMonth on openBackground show menubar hide message push recent card put (field 1 & line 1 of field year) into it set the name of this card to it if length of line 2 of field year < 2 then put "4 4" into line 2 of field Year -- default values for shifts in a row -- and number of shifts per day to schedule end if if (word 1 of line 3 of field year < 1) then put 1 into line 3 of field year -- personal menu set up global menu1,menu2 put NewMenu("Schedule","Requests On","Requests Off" ,"(-","Erase Schedule","Go To Next Month", "Go To Prior Month", "Extend Calendar","(-", "HELP") into menu1 if menu1 is 0 then answer ("Unable to make menu "Beep") with "Drat" put NewMenu("SetUp","Set Requests On","Set Requests Off","(-", "Set Max # Days in a Row", "Set # Shifts per Day","Set Salvos","(-", "Talley", "Go to Current Month", "Delete this Card") into menu2 if menu2 is 0 then answer ("Unable to make menu Visual") with "Drat" end OpenBackground on closebackground global menu1,menu2 put deleteMenu(menu1) into menu1 -- clearing global for safety put deleteMenu(menu2) into menu2 end closebackground on idle global menu1, menu2, lastTick if (the ticks-lastTick)>120 then put the ticks into lastTick ShowMenu(menu1) ShowMenu(menu2) end if pass idle end idle on doMenu which -- get menu items from doMenu before Hypercard does global menu1,menu2 if which is "Requests Off" then send "mouseUp" to bkgnd button "Schedule Off" else if which is "Requests On" then send "mouseUp" to bkgnd button "Schedule On" else if which is "Set Requests Off" then send "mouseUp" to bkgnd button "Requests Off" else if which is "Set Requests On" then send "mouseUp" to bkgnd button "Requests On" else if which is "Talley" then send "mouseUp" to bkgnd button "Talley" else if which is "Go to Current Month" then send "mouseUp" to bkgnd button "Show Current Month" else if which is "Erase Schedule" then send "mouseUp" to bkgnd button "Erase Sched" else if which is "Set Max # Days in a Row" then setDaysinaRow else if which is "Set # Shifts per Day" then setShiftsPerDay else if which is "Set Salvos" then ask "How days per Salvo... (1-5)" with "1" put it into line 3 of field "year" else if which is "Extend Calendar" then extend else if which is "Go To Next Month" then visual Effect Dissolve Fast doMenu Next else if which is "Go To Prior Month" then visual Effect Dissolve Fast doMenu Prev else if which is "Help" then visual Effect Dissolve Fast send "mouseUp" to bkgnd button "Help" else if which is "Delete this Card" then Answer "Are you Sure..." with "Yes" or "No" if it is "No" then exit doMenu doMenu Delete Card else pass doMenu -- pass on menu commands I don't trap end doMenu on SetDaysInaRow Ask "Limit Days in a Row to..." with "5" put it into word 1 of line 2 of field Year -- hide it here end SetDaysInaRow on setShiftsPerDay put 0 into it repeat until (it > 0 and it <= 4) Ask "How Many Shifts Per Day (1 - 4)" with "4" end repeat put " " & it into word 2 of line 2 of field year -- hide it here end setShiftsPerDay on LabelDays global firstofmonth, lastofmonth -- ***** now put which day of the week it is in each box ****** repeat with index = firstofmonth to lastofmonth put field 1 && word 1 of field index & "," & field 37 into it convert it to abbreviated date put word 1 of it into it put it into line 5 of field index end repeat end LabelDays on CheckButtons put Char 1 of word 1 of field 1 & char 1 of word 2 of field 1 into name global storage put "" into storage put "A B C D" into Shifts repeat with shift = 1 to 4 repeat with index = 1 to 31 put index+((shift-1)*31) into today -- there are 124 buttons to check if hilite of card button today = "True" then put word shift of Shifts & index & " " after storage -- storage looks like this ..A1 A3 A22 B12 C14 etc... end if end repeat end repeat put name & " " before storage end CheckButtons -- part 5 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=196 top=44 right=67 bottom=304 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 3 -- text size: 18 -- style flags: 256 -- line height: 24 -- part name: Month -- part 8 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=99 right=141 bottom=80 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 9 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=79 top=99 right=141 bottom=148 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 10 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=147 top=99 right=142 bottom=216 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 11 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=215 top=99 right=141 bottom=284 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 12 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=283 top=99 right=141 bottom=352 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 13 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=351 top=99 right=141 bottom=420 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 14 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=419 top=99 right=141 bottom=488 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 15 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=145 right=187 bottom=80 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 16 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=79 top=145 right=187 bottom=148 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 17 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=147 top=145 right=187 bottom=216 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 18 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=215 top=145 right=187 bottom=284 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 19 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=283 top=145 right=187 bottom=352 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 20 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=351 top=145 right=187 bottom=420 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 22 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=419 top=145 right=187 bottom=488 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 23 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=191 right=233 bottom=80 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 24 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=79 top=191 right=233 bottom=148 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 25 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=147 top=191 right=233 bottom=216 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 26 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=215 top=191 right=233 bottom=284 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 27 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=283 top=191 right=233 bottom=352 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 28 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=348 top=191 right=233 bottom=417 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 29 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=419 top=191 right=233 bottom=488 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 30 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=237 right=279 bottom=80 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 31 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=79 top=237 right=279 bottom=148 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 32 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=147 top=237 right=279 bottom=216 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 33 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=215 top=237 right=279 bottom=284 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 34 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=283 top=237 right=279 bottom=352 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 35 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=351 top=237 right=279 bottom=420 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 36 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=419 top=237 right=279 bottom=488 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 37 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=283 right=325 bottom=80 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 38 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=79 top=283 right=325 bottom=148 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 39 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=147 top=283 right=325 bottom=216 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 40 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=215 top=283 right=325 bottom=284 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 41 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=283 top=283 right=325 bottom=352 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 42 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=351 top=283 right=325 bottom=420 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 43 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=419 top=283 right=325 bottom=488 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 9 -- style flags: 0 -- line height: 10 -- part name: -- part 44 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=0 top=324 right=342 bottom=30 -- title width / last selected line: 0 -- icon id / first selected line: 20689 / 20689 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: go to home ----- HyperTalk script ----- on mouseUp go Home end mouseUp -- part 49 (field) -- low flags: 00 -- high flags: 0000 -- rect: left=10 top=43 right=62 bottom=66 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 14 -- style flags: 256 -- line height: 18 -- part name: Year -- part 53 (field) -- low flags: 80 -- high flags: 0000 -- rect: left=18 top=107 right=316 bottom=474 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: backfield -- part 55 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=138 top=0 right=15 bottom=219 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Schedule Off ----- HyperTalk script ----- On mouseup global shiftloopcount, storage, index, SalvoNum put line 3 of field year into SalvoNum Ask "How Many Shifts of type 'A' per Day(1-4)" with "1" if it > 4 or it < 1 then exitroutine exit mouseUp else put it into TypeANum put it & " " into ShiftLoopCount end if Ask "How Many Shifts of Type 'B' per Day (1-4)" with "1" if it > 4 or it < 1 then exitroutine exit mouseUp else put it into TypeBNum put it & " " after shiftLoopCount end if Ask "How Many Shifts of Type 'C' per Day (1-4)" with "1" if it > 4 or it < 1 then exitroutine exit mouseUp else put it into TypeCNum put it & " " after shiftLoopCount end if Ask "How Many Shifts of Type 'D' per Day (1-4)" with "1" if it > 4 or it < 1 then exitroutine exit mouseUp else put it into TypeDNum put it & " " after shiftLoopCount end if Hide Message set cursor to 4 set lockscreen to true -- Answer "Schedule people who WANT certain shifts? " with "Yes" or "No" -- if it contains "Yes" then -- put "Getting Requests On First" -- send mouseUp to bkgnd button "Schedule On" -- end if if (the length of line 5 of field 15 < 1) then -- pick some field in the middle SetUpCalendar LabelDays -- if the days haven't been labelled, do it now end if -- now get requests off for this month set cursor to 4 put "" into field 38 -- clear it out first put " I'm getting peoples requests for days off" put id of last card of bkgnd "Requests Off" into lastid -- for later checking put "False" into LastCardTest -- set THE Boolean to false put 0 into cardnum repeat until (LastCardTest="True") push card--push calendar card on to stack closebackground -- take care of the menus etc... put cardnum + 1 into cardnum -- increment this for each loop go to card cardnum of bkgnd "requests off" get id of card if it = lastid then put "True" into LastCardTest--if so... Stop GetData closebackground pop card put storage into line cardnum of field backfield end repeat if (number of lines of field 38 = 1) then answer "Only one person? - don't waste your time" exit mouseUp end if BeginToSchedule end mouseUp on BeginToSchedule global employeenum, Name, index, shift, shiftloopcount, employee global firstofmonth, lastofmonth, shifnum, subindex, DaysInaRowLimit global limitpointer, SalvoNum set cursor to 4 put "A B C D" into shifts put word 2 of line 2 of field year into shifnum put word 1 of line 2 of field "Year" into it put it - 1 into DaysInaRowLimit put the number of lines of field 38 into employeenum SetUpCalendar -- find first and last of month set lockscreen to false -- let's watch it work repeat with index = firstofmonth to lastofmonth -- day by day put word 1 of line 1 of field index after line 6 of field index -- save date we'll put it back later put "" into word 1 of line 1 of field index--strip leading blanks put "" before word 1 of line 1 of field index repeat with subindex = 1 to Shifnum -- sched all 4 shifts day by day -- ********* put word subindex of shiftloopcount into shiftloop -- how people pert shift put word subindex of shifts into shift -- how many shifts repeat with subsubindex = 1 to shiftloop if number of words of line subindex of field index < (shiftloop) then -- if not full up... proceed GetAWorker PutName -- remember to count down the number of days they're available if (Name contains "**") then next repeat -- but not if it's 'no name' CountDown if SalvoNum > 1 then Salvo end if else -- if already done ... skip this part wait 1 -- later may use this area to keep a running total end if end repeat end repeat put last word of line 6 of field index before line 1 of field index put "" into line 6 of field index end repeat end BeginToschedule On GetAWorker Global employeenum, Name, Date, Answer, employee, index put "False" into Cycled put "False" into Looped put "False" into Date -- set the Boolean put random (employeenum) into seed -- start looking in a random spot put seed into employee Repeat until (Cycled = "True") put First word of line employee of field 38 into Name shiftLimittest-- first test of potential to work if Answer = "Yes" then AvailabilityTest--check for day off requested if answer = "Yes" then NightMorningTest--did they work last shift of yesterday if answer = "Yes" then DaysInaRowTest --within our limits for days in a row? if answer = "No" then -- if any test says, NO...they can't be put on put "**" into Name -- is left like this if no one available else put "Filled" into Date exit GetaWorker -- got a name - no need to stick around end if if (employee = employeenum) then put 1 into employee put "true" into looped else put (employee + 1) into employee end if if employee = seed AND looped = "true" then put "True" into Cycled end if -- if we've gone through everyone once, then quit...(a full cycle) end repeat end GetAWorker On AvailabilityTest -- Just determines if a person is 'available' global employee, Name, Date, Answer, index, Shift,Shifnum if field index contains Name then -- are they already scheduled for today put "No" into answer -- if so... else if line employee of field 38 contains (" " & first word of line 6 of field index & shift) -- remember we've hidden the date here then put "No" into answer else put "Yes" into answer -- yes he is available end if end if end AvailabilityTest on NightMorningTest -- Does not allow someone to work the night before -- and the morning after (e.g. graveyard on the 3rd, AM on the 4th!!) global shifnum, Name, index, subindex, answer if subindex = 1 then -- we only need to do this test on the first shift if line shifnum of field (index - 1) contains Name then put "No" into answer -- tell the prog this person's unavailable end if end NightMorningTest On DaysInaRowTest global DaysInaRowLimit, index, subindex, Name, firstofmonth,answer global shifnum put "" into LimitReached -- intitialize put index into here if (index - daysInaRowLimit) > firstofmonth then put (index - daysInaRowLimit - 1) into there -- otherwise, its the first days of month, skip it Repeat with rowindex = (here - 1) down to there if field rowindex contains Name then put "No" into Answer--set default to 'not available'...keep looking else -- however, if anywhere along the 'days in a row' we're looking put "Yes" into Answer --we don't find the person, then they're exit repeat --available, and we don't need to look further end if end repeat end if end DaysInaRowTest on GetData Global Storage put first char of first word of field "Name" & first char of second word of field "Name" && field "data" into storage put " " & field Shiftlimit1¬ -- weekday limits & " " & field Shiftlimit2 & " " ¬ -- weekend limits after word 1 of storage -- storage should look like this -- Abbrev.Name limitA limitB limitC limitD limitA limitB limitC LIMITD .... end GetData on ShiftLimitTest global employee, name, Date, Answer, index, shift, subindex, shiftnum global limitpointer if first char of line 5 of field index = "S" -- if its Sat or Sun then put (5 + subindex) into limitpointer else put (1 + subindex) into limitpointer end if if (word (limitpointer) of line employee of field 38 <= 0) then put "No" into answer else put "Yes" into answer end if end ShiftLimitTest on CountDown global limitpointer, employee put word (limitpointer) of line employee of field 38 into holder put (holder - 1) into holder put holder into word (limitpointer) of line employee of field 38 end CountDown On ExitRoutine answer "You exceeded the limits - Start Over" end ExitRoutine On Salvo global employeenum, Name, index, shift, shiftloopcount, employee global firstofmonth, lastofmonth, shifnum, subindex, DaysInaRowLimit global limitpointer, SalvoNum, Answer put index into holder-- save the original index repeat with index = (index + 1) to (index + salvonum) if index > lastofmonth then put holder into index exit salvo end if put word 1 of line 1 of field index into line 6 of field index put "" into word 1 of field index availabilityTest shiftLimitTest -- do these two tests, if answer is Yes keep going if Answer = "Yes" then DaysInARowTest if Answer = "Yes" then PutName CountDown put last word of line 6 of field index before line 1 of field index put "" into line 6 of field index else put last word of line 6 of field index before line 1 of field index put "" into line 6 of field index put holder into index exit salvo end if else put last word of line 6 of field index before line 1 of field index put "" into line 6 of field index put holder into index exit Salvo end if end repeat put holder into index -- put the original index back end Salvo On PutName global Name, subindex, index Put " " & Name after line subindex of field index end PutName -- part 56 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=0 top=0 right=16 bottom=40 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Requests OFF ----- HyperTalk script ----- on mouseUp push card closebackground go to Background "Requests Off" end mouseUp -- part 57 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=306 top=0 right=12 bottom=388 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: ERASE Sched ----- HyperTalk script ----- on mouseUp answer "Are You Sure?!" with "Yes" or "No" if it is "yes" then set cursor to 4 repeat with index = 2 to 36 set style of field index to transparent put word 1 of field index into wordstor put wordstor into field index end repeat else end if end mouseUp -- part 58 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=446 top=7 right=19 bottom=512 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: HELP ----- HyperTalk script ----- on mouseUp push card go to first card of stack "Scheduler Help" end mouseUp -- part 60 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=78 top=0 right=15 bottom=138 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Requests ON ----- HyperTalk script ----- on mouseUp push card closebackground go to bkgnd "Requests On" end mouseUp -- part 61 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=219 top=0 right=12 bottom=304 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Schedule on ----- HyperTalk script ----- on mouseUp global storage global firstofmonth global lastofmonth, ShiftLoopCount,storage, index set cursor to 4 -- change cursor to the watch icon Ask "How Many Shifts of type 'A' per Day" with "3" put it into TypeANum put it & " " into ShiftLoopCount Ask "How Many Shifts of Type 'B' per Day" with "1" put it into TypeBNum put it & " " after shiftLoopCount Ask "How Many Shifts of Type 'C' per Day" with "4" put it into TypeCNum put it & " " after shiftLoopCount Ask "How Many Shifts of Type 'D' per Day" with "2" put it into TypeDNum put it & " " after shiftLoopCount set lockscreen to true hide menubar hide message -- don't wast time updating the screen set visible of background field "backfield" to false put "" into field backfield -- clear this field -- I'm going to import data to this -- field (38) so I don't have to keep -- going back and forth to stacks while figuring put id of last card of bkgnd "Requests On" into lastid -- for later checking put "False" into LastCardTest -- first set the Boolean to false put 0 into cardnum -- initialize for the first card repeat until (LastCardTest = "True")--continue until the last card push card--push calendar card on to stack closebackground -- take care of the menus etc... put cardnum + 1 into cardnum -- increment this for each loop Put "Looking at Card " & Cardnum & " Now" go to card cardnum of bkgnd "requests on" get id of card if it = lastid then put "True" into LastCardTest--if so... Stop put field "data" into storage closebackground pop card put storage into line cardnum of field backfield end repeat put "Setting up the Calendar" SetUpCalendar-- find field for first & last of month & label the days Hide message if length of line 5 of field 15 < 2 then -- if it's not been labeled LabelDays-- put Mon, Tues,... the short date, on line five @each field end if Set lockscreen to False PlaceinSchedule end mouseup on PlaceinSchedule set cursor to 4 global firstofmonth, lastofmonth, shiftLoopCount,maxpeople, answer,shift global index put word 2 of line 2 of field year into shiftnum put "A B C D" into Shifts put the number of lines in field 38 into employeenum repeat with shift = 1 to shiftnum put word shift of shifts into testshift put word shift of shiftloopcount into maxpeople repeat with employee = 1 to employeenum if line employee of field 38 contains testshift then repeat with index = firstofmonth to lastofmonth if line employee of field 38 contains " " & word 1 of field index & testshift then MaxPeopleTest set cursor to 4 -- reset it if answer = "Yes" then put " " & word 1 of line employee of field 38 after line shift of field index end if end if end repeat end if end repeat end repeat end PlaceinSchedule On MaxPeopleTest global shift, maxpeople, index, Answer put the number of words in line shift of field index into currentnum if shift = 1 then put currentnum - 1 into currentnum -- don't count the date end if set style of field index to shadow set style of field index to transparent -- some feedback indicating were working if currentNum = maxpeople then put "No" into Answer else put "Yes" into Answer end if end MaxPeopleTest -- part 62 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=41 top=2 right=16 bottom=76 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: talley ----- HyperTalk script ----- on mouseUp global themonth get name of this card put it into themonth push card visual barn door open go to background "Talley" end mouseUp -- part 65 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=393 top=0 right=12 bottom=512 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show Current Month ----- HyperTalk script ----- on mouseUp get the seconds convert it to long date put word 2 of it into month put word 4 of it into year put month&year into thismonth visual effect checkerboard go to card thismonth of stack "scheduler" end mouseUp -- part 67 (button) -- low flags: 00 -- high flags: 8002 -- rect: left=0 top=2 right=20 bottom=512 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show Menus ----- HyperTalk script ----- on mouseUp show menubar hide message end mouseUp -- part 68 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=397 top=42 right=71 bottom=433 -- title width / last selected line: 0 -- icon id / first selected line: 22308 / 22308 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Next Card ----- HyperTalk script ----- on mouseUp get id of card put id of last card of background "SCHEDULER" into lastcard if it = lastcard then go to first card of background "SCHEDULER" else visual effect wipe right go to next card of bkgnd "SCHEDULER" end if end mouseUp -- part 69 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=72 top=42 right=72 bottom=107 -- title width / last selected line: 0 -- icon id / first selected line: 19381 / 19381 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Prior Card ----- HyperTalk script ----- on mouseUp get id of card put id of first card of background "SCHEDULER" into firstcard if it = firstcard then visual effect wipe left go to last card of background "SCHEDULER" else visual effect wipe left go to previous card of bkgnd "SCHEDULER" end if end mouseUp -- part 71 (button) -- low flags: 00 -- high flags: 8000 -- rect: left=437 top=34 right=80 bottom=496 -- title width / last selected line: 0 -- icon id / first selected line: 25002 / 25002 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Help Me! ----- HyperTalk script ----- on mouseUp visual effect dissolve fast go to bkgnd "Quick Help" end mouseUp