7 Replies Latest reply on Oct 7, 2010 1:00 PM by thong127

    Loop

    thong127

      Title

      Loop

      Post

      Hello to everybody,

      Just want to ask for a help. I made a 6 countdown timer for 6 different machines. (Machine 39, 40, 41, 53, 54 & 55). my table (Dissolution) has the following fields:

      Dissolution Counter 39;Dissolution Counter 40;Dissolution Counter 41; Dissolution Counter 53; Dissolution Counter 54; Dissolution Counter 55. their type is Time and Option is Global and I have also

      Dissolution Message 39, Dissolution Message 40, Dissolution Message 41, Dissolution Message 53, Dissolution Message 54, Dissolution Message 55. Their type is Text and the option is Global.

      My Scripts is run like this

      Set Field [Dissolution::Dissolution Counter:39; 100]

      Loop

      Set Field [Dissolution::Dissolution Message 39; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 39)]

      Set Field[Dissolution::Dissolution Counter:39; Dissolution::Dissolution Counter:39-1]

      Pause/Resume Script [Duration (seconds); Time(0; 0; 3)]

      Exit Loof If [GetAsTime (Dissolution::Dissolution Counter:39)=0]

      End Loop

      (Same with 40, 41, 53, 54 & 55 but I changed the counter number & message number)

      I Tried to run my scripts only one can run at a time...my problem now is How can I run the 6 scripts at the same time when they are using all the 6 machines? kindly suggest to improve my script to make a single script so that I can run them all the countdown timer all at a time.

      Thank you in advanced.

       

      ThongLoreto

       

       

        • 1. Re: Loop
          RickWhitelaw

          "Set Field[Dissolution::Dissolution Counter:39" shouldn't have ":" before 39 if your naming scheme earlier in your post is accurate.

          Scripts in FM run one at a time. However, I see no mention of "Machine" in your script and I'm not clear what you mean by machine. You probably could , if your machines were numbered with consecutive digits (39,40,41,42 etc.) use a Set Variable step in another loop which would increase the machine ID. Your current loop would then run "inside" this higher level loop. 

          Assuming you wanted your machine IDs to be "Machine39","Machine40" etc. the script below would do. 

          Set Variable [ $MNumber; Value:39 ]

          Loop

          Set Variable [ $Machine; Value:"Machine"&$MNumber ]

          //do your stuff here//

          Set Variable [ $MNumber; Value:$MNumber+1 ]

          Exit Loop If [ $MNumber>44 ] //or whatever number you need//

          End Loop

          There's more to it than that, but that's all I can suggest with the information provided.

          RW

          • 2. Re: Loop
            thong127

            @RickWhitelaw thanks for answering... the machines that im saying is our dissolution machines in our office.

            I changed my scripts and it looks like these now.

            Set Field [Dissolution::Dissolution Counter:39]

            Set Field [Dissolution::Dissolution Counter:40]

            Set Field [Dissolution::Dissolution Counter:41]

            Set Field [Dissolution::Dissolution Counter:53]

            Set Field [Dissolution::Dissolution Counter:54]

            Set Field [Dissolution::Dissolution Counter:55]

            Loop

            Set Field [Dissolution::Dissolution Message 39; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 39)]

            Set Field [Dissolution::Dissolution Message 40; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 40)]

            Set Field [Dissolution::Dissolution Message 41; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 41)]

            Set Field [Dissolution::Dissolution Message 53; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 53)]

            Set Field [Dissolution::Dissolution Message 54; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 54)]

            Set Field [Dissolution::Dissolution Message 55; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 55)]

            Set Field[Dissolution::Dissolution Counter:39; Dissolution::Dissolution Counter:39-1]

            Set Field[Dissolution::Dissolution Counter:40; Dissolution::Dissolution Counter:40-1]

            Set Field[Dissolution::Dissolution Counter:41; Dissolution::Dissolution Counter:41-1]

            Set Field[Dissolution::Dissolution Counter:53; Dissolution::Dissolution Counter:53-1]

            Set Field[Dissolution::Dissolution Counter:54; Dissolution::Dissolution Counter:54-1]

            Set Field[Dissolution::Dissolution Counter:55; Dissolution::Dissolution Counter:55-1]

            Exit Loop If [GetAsTime (Dissolution::Dissolution Counter:39)=0]

            Exit Loop If [GetAsTime (Dissolution::Dissolution Counter:40)=0]

            Exit Loop If [GetAsTime (Dissolution::Dissolution Counter:41)=0]

            Exit Loop If [GetAsTime (Dissolution::Dissolution Counter:53)=0]

            Exit Loop If [GetAsTime (Dissolution::Dissolution Counter:54)=0]

            Exit Loop If [GetAsTime (Dissolution::Dissolution Counter:55)=0]

            Pause/Resume Script [Duration (seconds); Time(0; 0; 3)]

            End Loop

            Kindly suggest for the improvement of my scripts beacuse if Dissolution counter 39 get first  zero(0) the dissolution counter 40, 41, 53, 54, 55 stop.

            thank you very much

            • 3. Re: Loop
              RickWhitelaw

              The script will exit the loop once the first "Exit Loop If" conditions are met. What I'm suggesting is dealing with each machine consecutively but in a single script.

              RW

              • 4. Re: Loop
                philmodjunk

                Here's a "brute force" fix of your script:

                Set Field [Dissolution::Dissolution Counter39]
                Set Field [Dissolution::Dissolution Counter40]
                Set Field [Dissolution::Dissolution Counter41]
                Set Field [Dissolution::Dissolution Counter53]
                Set Field [Dissolution::Dissolution Counter54]
                Set Field [Dissolution::Dissolution Counter55]
                Loop
                       Set Field [Dissolution::Dissolution Message 39; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 39)]
                       Set Field [Dissolution::Dissolution Message 40; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 40)]
                       Set Field [Dissolution::Dissolution Message 41; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 41)]
                       Set Field [Dissolution::Dissolution Message 53; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 53)]
                       Set Field [Dissolution::Dissolution Message 54; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 54)]
                       Set Field [Dissolution::Dissolution Message 55; "Finish in" & GetAsTime(Dissolution::Dissolution Counter 55)]
                       Set Field[Dissolution::Dissolution Counter39; If ( Dissolution::Dissolution Counter39 > 0 ;Dissolution::Dissolution Counter39-1 ; Dissolution::Dissolution Counter39 ) ]
                       Set Field[Dissolution::Dissolution Counter40; If ( Dissolution::Dissolution Counter40 > 0 ;Dissolution::Dissolution Counter40-1 ; Dissolution::Dissolution Counter40 )]
                       Set Field[Dissolution::Dissolution Counter41; If ( Dissolution::Dissolution Counter41 > 0 ;Dissolution::Dissolution Counter41-1 ; If ( Dissolution::Dissolution Counter41 > 0 ;Dissolution::Dissolution Counter41-1 ; Dissolution::Dissolution Counter41 ) )]
                       Set Field[Dissolution::Dissolution Counter53; If ( Dissolution::Dissolution Counter53 > 0 ;Dissolution::Dissolution Counter53-1 ; Dissolution::Dissolution Counter53 )]
                       Set Field[Dissolution::Dissolution Counter54; If ( Dissolution::Dissolution Counter54 > 0 ;Dissolution::Dissolution Counter54-1 ; Dissolution::Dissolution Counter54 )]
                       Set Field[Dissolution::Dissolution Counter:55; If ( Dissolution::Dissolution Counter55 > 0 ;Dissolution::Dissolution Counter55-1 ; Dissolution::Dissolution Counter55 )]
                       Exit Loop If [Sum ( Dissolution::Dissolution Counter39 ; Dissolution::Dissolution Counter40 ; Dissolution::Dissolution Counter41; Dissolution::Dissolution Counter53 ; Dissolution::Dissolution Counter54 ; Dissolution::Dissolution Counter55)=0]
                       Pause/Resume Script [Duration (seconds); Time(0; 0; 3)]
                End Loop

                Using a table of related records with one record per timer would make for a much simpler script here.

                • 5. Re: Loop
                  thong127

                  Hi PhilmodJunk,

                  Thanks for helping..I tried your suggestion and its working now, but I have a problem with regards to the scripts. because when I run the script..I noticed that the countdown in seconds is slow when the three (3) counter is running (counter39, counter40, counter41...53,54 & 55) (...can you please suggest a way so that when I run the script makes it faster like ordinary countdown in a countdown clock.

                  Thank you very much.

                  • 6. Re: Loop
                    philmodjunk

                    I don't know of any way you can get the counters to count down by one and be synched to countdown the seconds. If it were counting down too fast, you might be able to build in a delay so that it more or less stays in synch as long as your system performance doesn't change, but in your case, it's too slow.

                    Best you could do, I think, is to store the current time in a variable at the start of the script and decrement each counter by subtracting ( Get ( CurrentTime ) - $StartTime ) from each counter. That will cause the counters to skip a value now and then to stay in synch with the elapsed time in seconds.

                    • 7. Re: Loop
                      thong127

                      Hi PhilModJunk,

                       

                      I figure it out ...I changed the pause resume script duration into 1.

                      Thank you very much.