Calculate Time of shifts

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
viro
Posts: 52
Joined: Fri Jul 05, 2013 6:59 pm

Calculate Time of shifts

Post by viro » Tue Apr 15, 2014 4:03 pm

Hello folks,
for my current project i need to determine the time and dependend on this time choose the right shift.
After the right shift and time is chosen, it should calculate remaining time until shift end and pause within given timeperiods.
Is this to much to pack into livecode?
Thats my current handler to set the shift time..

Code: Select all

command calcSchicht
   local vTarget, vItems
   set the itemdel to tab
   put the cSchicht of this stack into vTarget
   put "Administration"&tab&"QCD Anzeigetafel" into vItems
   if the cSchicht of this stack is "S1" then
      repeat for each item i in vItems
         set the colorOverlay["opacity"] of fld vTarget of card i to "255"
         set the colorOverlay["color"] of fld vTarget of card i  to "blue"
         set the colorOverlay["blendMode"] of fld vTarget of card i to "multiply"
         set the colorOverlay["opacity"] of fld "S2" of card i to "0"
         set the colorOverlay["opacity"] of fld "S3" of card i to "0"
      end repeat
      set the colorOverlay["opacity"] of fld "AS1" of card 1 to "255"
      set the colorOverlay["color"] of fld "AS1" of card 1  to "blue"
      set the colorOverlay["blendMode"] of fld "AS1" of card 1 to "multiply"
      set the colorOverlay["opacity"] of fld "AS2" of card 1 to "0"
      set the colorOverlay["opacity"] of fld "AS3" of card 1 to "0"
      if the cWoche of this stack is "W40"  then
         set the cArbeitszeit of this stack to "480"
         #put item 2 of line 1 of fld "40w" of card "Administration" of this stack into vStart
         #put item 3 of line 1 of fld "40w" of card "Administration" of this stack into vEnd
      else
         set the cArbeitszeit of this stack to "450"
         #put item 2 of line 1 of fld "375w" of card "Administration" of this stack into vStart
         #put item 3 of line 1 of fld "375w" of card "Administration" of this stack into vEnd
      end if
   else if the cSchicht of this stack is "S2" then
      repeat for each item i in vItems
         set the colorOverlay["opacity"] of fld vTarget of card i to "255"
         set the colorOverlay["color"] of fld vTarget of card i  to "blue"
         set the colorOverlay["blendMode"] of fld vTarget of card i to "multiply"
         set the colorOverlay["opacity"] of fld "S1" of card i to "0"
         set the colorOverlay["opacity"] of fld "S3" of card i to "0"
      end repeat
      set the colorOverlay["opacity"] of fld "AS2" of card 1 to "255"
      set the colorOverlay["color"] of fld "AS2" of card 1  to "blue"
      set the colorOverlay["blendMode"] of fld "AS2" of card 1 to "multiply"
      set the colorOverlay["opacity"] of fld "AS1" of card 1 to "0"
      set the colorOverlay["opacity"] of fld "AS3" of card 1 to "0"
      if the cWoche of this stack is "W40"  then
         set the cArbeitszeit of this stack to "480"
         #put item 2 of line 2 of fld "40w" of card "Administration" of this stack into vStart
         #put item 3 of line 2 of fld "40w" of card "Administration" of this stack into vEnd
      else
         set the cArbeitszeit of this stack to "450"
         #put item 2 of line 2 of fld "375w" of card "Administration" of this stack into vStart
         #put item 3 of line 2 of fld "375w" of card "Administration" of this stack into vEnd
      end if
   else if the cSchicht of this stack is "S3" then
      repeat for each item i in vItems
         set the colorOverlay["opacity"] of fld vTarget of card i to "255"
         set the colorOverlay["color"] of fld vTarget of card i  to "blue"
         set the colorOverlay["blendMode"] of fld vTarget of card i to "multiply"
         set the colorOverlay["opacity"] of fld "S1" of card i to "0"
         set the colorOverlay["opacity"] of fld "S2" of card i to "0"
      end repeat
      set the colorOverlay["opacity"] of fld "AS3" of card 1 to "255"
      set the colorOverlay["color"] of fld "AS3" of card 1  to "blue"
      set the colorOverlay["blendMode"] of fld "AS3" of card 1 to "multiply"
      set the colorOverlay["opacity"] of fld "AS2" of card 1 to "0"
      set the colorOverlay["opacity"] of fld "AS1" of card 1 to "0"
      if the cWoche of this stack is "W40"  then
         set the cArbeitszeit of this stack to "480"
         #put item 2 of line 3 of fld "40w" of card "Administration" of this stack into vStart
         #put item 3 of line 3 of fld "40w" of card "Administration" of this stack into vEnd
      else
         set the cArbeitszeit of this stack to "450"
         #put item 2 of line 3 of fld "375w" of card "Administration" of this stack into vStart
         #put item 3 of line 3 of fld "375w" of card "Administration" of this stack into vEnd
      end if
   end if
   #replace ":" with "" in vStart
   #replace ":" with "" in vEnd
   #put vEnd-vStart into vArbeitszeit
   #put (vArbeitszeit *60)/100 into vArbeitszeit
   #set the cArbeitszeit of this stack to vArbeitszeit
   updateFields
end calcSchicht
thanks in advance
the funniest thing about this particular signature is that by the time you realize it doesn't say anything it's too late to stop reading it

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Calculate Time of shifts

Post by atout66 » Tue Apr 15, 2014 4:32 pm

Hi viro,

Not sure if it can help you, but you may have a look at this post by chance...
http://forums.runrev.com/viewtopic.php?f=7&t=19906

The answer is at the bottom, in the latest responses, not mine :wink:

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

viro
Posts: 52
Joined: Fri Jul 05, 2013 6:59 pm

Re: Calculate Time of shifts

Post by viro » Wed Apr 16, 2014 9:11 am

I think you didnt get me right :O

I try to build a stack which automaticly starts and stops different handlers based on given shift times...

i attached a stack which shows what i mean.

1.Cant imagine how to build pauses into shifts, so that every handler pauses.
2. need a comfortable way of modifying the times

hopefully some could help me

sincerly viro
Attachments
shift calculator.zip
(1.58 KiB) Downloaded 208 times
the funniest thing about this particular signature is that by the time you realize it doesn't say anything it's too late to stop reading it

Post Reply