Timer Soultion With luaCOM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    Timer Soultion With luaCOM

    ok, i knew there had to be a way to get around this timer issue, thanks to the "AR Timer ActiveX Library 2.0" you can now have unlimited independant timers

    ok, its not the prettiest of timer code but it works and its reliable (some vista feedback plz :yes)

    Code:
    -- create Timer1
    Timer1 = luacom.CreateObject("ARTimerLib.ARTimer")
    if Timer1 then
    	
    	-- set timer interval
    	Timer1.Interval = 1
    	
    	-- this is the events table for Timer1
    	Timer1Event={} 
    	
    	-- now connect to the timer events
    	luacom.Connect(Timer1,Timer1Event)
    	
    	-- This event will be fired every time that the amount of time set in Interval is elapsed. 
    	-- TT_H, TT_M, TT_S and TT_MS will contain the total amount of time elapsed since the timer was started. 
    	-- For convenience, hours, minutes, seconds and milliseconds are given in different variables.
    	
    	function Timer1Event:Timer(nH, nM, nS, nMS)
    		-- put your timer actions here
    		Label.SetText("Label1", nH..nM..nS..nMS);
    		
    		
    		-- just to test, make sure the timer dosent go above 5 seconds
    		if nS == 5 then
    			Timer1:StopTimer()
    		end
    	end
    	
    	-- now start the timer
    	Timer1:StartTimer()
    else
    	-- there was an error, make sure the ocx is registerd
    	result = Dialog.Message("Error", "Could not create Timer1", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    and remember to register the ocx and add the luaCOM plugin to the project
    Last edited by RizlaUK; 02-01-2009, 11:34 AM.
    Embrace change in your life, you never know, it could all work out for the best
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    #2
    there is a count down timer to, could be useful

    Code:
    -- create CountDown1
    CountDown1 = luacom.CreateObject("ARTimerLib.ARCountdown")
    if CountDown1 then
    	-- set countdown interval (5 second countdown)
    	CountDown1.Interval = 5000
    	-- this is the events table for CountDown1
    	CountDown1Event={} 
    	-- now connect to the countdown events
    	luacom.Connect(CountDown1,CountDown1Event)
    	
    	-- This event is fired once the time has elapsed. 
    	-- If you want to run the countdown again, use the StartCountdown method.
    	function CountDown1Event:Done()
    		-- put your countdown actions here
    		Label.SetText("Label2", "TimeUp!");
    
    		
    	end
    	
    	-- start the countdown
    	CountDown1:StartCountdown()
    	
    else
    	-- there was an error, make sure the ocx is registerd
    	result = Dialog.Message("Error", "Could not create CountDown1", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    end
    Embrace change in your life, you never know, it could all work out for the best

    Comment

    • ShadowUK
      No longer a forum member
      • Oct 2007
      • 1322

      #3
      Very nice, people coming up with a lot of methods recently.

      Comment

      • HMMurdock
        Forum Member
        • Mar 2005
        • 144

        #4
        Originally posted by RizlaUK View Post
        (some vista feedback plz :yes)
        For some reason, I can't even get the dll to register in Vista. Even with UAC disabled and run as an adminisrator, I get an error message from regsvr32.

        "TheSpecified Module could not be found"

        I've double checked the path is correct. Even tried copying the dll to the System32 folder and running:

        regsvr32 c:\windows\system32\ARTimer.dll

        Same error.

        Vista is really starting to chap my tuckus.

        It runs like a champ on my XP machine though. Thanks for the info... nice find. I'll let you know if I find anything else out about Vista compatablilty.

        Comment

        • HMMurdock
          Forum Member
          • Mar 2005
          • 144

          #5
          When I added the following 2 lines of code after the "System.RegisterActiveX"

          Code:
          result = Application.GetLastError();
          Dialog.Message("Notice", "Error "..result..": ".._tblErrorMessages[result], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
          I get the following:

          Error 1802: Failure in LoadLibrary()

          Anyone care to speculate what that means?

          Comment

          • RizlaUK
            Indigo Rose Customer
            • May 2006
            • 5552

            #6
            off the top of my head,

            i once had a problem with a ocx that was made in vb6, its would not work on machines without vb runtimes, but i think the vb runtimes are in vista already so it may not be that.

            im working on a ocx right now, its proving to be easyer than i tought it was going to be, see if this runs on vista when its done.
            Embrace change in your life, you never know, it could all work out for the best

            Comment

            • RizlaUK
              Indigo Rose Customer
              • May 2006
              • 5552

              #7
              here, try this ocx on vista, it only supports 10 timers for now (for each object)

              i will tidy the function setup if this works ok, its only a test for now
              Last edited by RizlaUK; 02-01-2009, 11:34 AM.
              Embrace change in your life, you never know, it could all work out for the best

              Comment

              • Imagine Programming
                Indigo Rose Customer
                • Apr 2007
                • 4252

                #8
                Very nice rizla! thanks
                Bas Groothedde
                Imagine Programming :: Blog

                AMS8 Plugins
                IMXLH Compiler

                Comment

                • HMMurdock
                  Forum Member
                  • Mar 2005
                  • 144

                  #9
                  Originally posted by RizlaUK View Post
                  here, try this ocx on vista, it only supports 10 timers for now (for each object)

                  i will tidy the function setup if this works ok, its only a test for now
                  Okay... Well I figured out the issue with the first timer...

                  When I closed AMS7 (not the Timer App) Vista was kind enough to inform me that AMS7 (not the Timer App) was missing msvbvm50.dll... blah blah... deprecated windows files... blah blah...

                  Copied the dll file from another machine, and the first timer works like a champ.

                  (I only found all of that out when I went to close AMS so I could open up the new OCX project you just posted)

                  Anyway... the new OCX project seems to work fine on Vista. I haven't really toyed with it, much, but it didn't do anything unexpected. I'll test it further though.

                  Thanks for your hard work!

                  Comment

                  • RizlaUK
                    Indigo Rose Customer
                    • May 2006
                    • 5552

                    #10
                    ok, as i tought, vb runtimes, i posted a dependancy module for that a few weeks ago

                    wow, my ocx works on vista, ok then i'll work on it a little more then and add some more timers.

                    i figure the way my timer works is better because it only creates 1 activex object, the 1st one need a new object for each new timer

                    i will work on this a little more and post a release, in the mean time could i have some more feedback from all that would use this (i would imagine that would be quite a lot of you) most of all some vista feedback
                    Embrace change in your life, you never know, it could all work out for the best

                    Comment

                    • Dermot
                      Indigo Rose Customer
                      • Apr 2004
                      • 1791

                      #11
                      Originally posted by RizlaUK View Post
                      here, try this ocx on vista, it only supports 10 timers for now (for each object)

                      i will tidy the function setup if this works ok, its only a test for now
                      Great job. Works great on Vista.:yes:yes
                      Dermot

                      I am so out of here :yes

                      Comment

                      • RizlaUK
                        Indigo Rose Customer
                        • May 2006
                        • 5552

                        #12
                        great, iv now got a timer ocx with 50 timers each with its own event function

                        the timer now sends its cycle count to the event so no variables are needed

                        Code:
                        	function TimerEvents:Timer1(nCycle)
                        		-- put your timer actions here
                        		Label.SetText("Label1", nCycle);
                        		if nCycle == 20 then
                        			Timer:Reset(1)
                        		end
                        	end
                        the ocx has 4 methods

                        Code:
                        Timer:StartTimer(nTimer,nInterval)
                        Timer:StopTimer(nTimer)
                        Timer:SetInterval(nTimer,nInterval)
                        Timer:Reset(nTimer)
                        i will have a example ready soon :yes
                        Embrace change in your life, you never know, it could all work out for the best

                        Comment

                        • Dermot
                          Indigo Rose Customer
                          • Apr 2004
                          • 1791

                          #13
                          Originally posted by RizlaUK View Post
                          great, iv now got a timer ocx with 50 timers each with its own event function

                          the timer now sends its cycle count to the event so no variables are needed

                          Code:
                          	function TimerEvents:Timer1(nCycle)
                          		-- put your timer actions here
                          		Label.SetText("Label1", nCycle);
                          		if nCycle == 20 then
                          			Timer:Reset(1)
                          		end
                          	end
                          the ocx has 4 methods

                          Code:
                          Timer:StartTimer(nTimer,nInterval)
                          Timer:StopTimer(nTimer)
                          Timer:SetInterval(nTimer,nInterval)
                          Timer:Reset(nTimer)
                          i will have a example ready soon :yes
                          What! only 50 timers? Just kidding, sounds perfect.
                          Dermot

                          I am so out of here :yes

                          Comment

                          • qwerty
                            Forum Member
                            • Oct 2006
                            • 345

                            #14
                            thank you

                            Comment

                            • RizlaUK
                              Indigo Rose Customer
                              • May 2006
                              • 5552

                              #15
                              the final release got posted here (for anyone that missed it)
                              Embrace change in your life, you never know, it could all work out for the best

                              Comment

                              Working...
                              X