Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Is it possible to have more than one timer on a desktop form?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is it possible to have more than one timer on a desktop form?

    For example, how could I check something every 60 seconds and something else every 90 seconds.
    The reason I wish to do this is to ensure the second check takes place 30 seconds after first check.

    I realise I should be able to code a script somehow, just wondered if there was a way around the 1 timer limitation.

    Thanks

    #2
    Re: Is it possible to have more than one timer on a desktop form?

    No.
    There can be only one.

    Comment


      #3
      Re: Is it possible to have more than one timer on a desktop form?

      Abrupt :)

      But thanks

      Comment


        #4
        Re: Is it possible to have more than one timer on a desktop form?

        Only one timer.

        You might try setting the ontimer event to 30 seconds. Then in the onTimer script use the MOD() function twice to direct the flow of program execution. In one case the numerator would be time elapsed (in seconds) and denominator would be 60. When the remainder is zero you know 60 seconds have passed. In the second the numerator would be time elapsed (in seconds) and denominator would be 90. When the remainder is zero you know 90 seconds have passed.

        This will not force the second sequence to always be 30 seconds after the first, of course. But it will assure that one sequence fires every 60 seconds, and the other fires every 90, per your stated requirements. For example the first sequence will fire at 120 seconds, but the second won't fire again until elapsed time reaches 180, and that's when the first sequence would also fire.

        It may be time to rethink your stated requirements.

        Comment


          #5
          Re: Is it possible to have more than one timer on a desktop form?

          On second thought I suppose a single mod() "branch" in the code might be all that's needed. Check every 30 seconds. use MOD() to determine if 60 has elapsed. Raise a flag and branch to your every 60 second code. When ontimer fires again you know another 30 have passed if the flag is still raised, so branch to other code after first lowering the flag.

          Comment


            #6
            Re: Is it possible to have more than one timer on a desktop form?

            You could do something like this:
            Set the timer to 30 sec
            Put a numeric variable on your form, let's call it: t_lpsd and set its initial value to 0
            In the OnTimer Event, put a script like this:
            Code:
            t_lpsd.value=t_lpsd.value+1
            if mod(t_lpsd.value,2)=0
            ..run your first script...
            else
            if mod(t_lpsd.value,3)=0
            ..run second script..
            end if

            Comment


              #7
              Re: Is it possible to have more than one timer on a desktop form?

              Apologies. The script as written, I think and without testing it, will encounter a self-defeating timing issue (has nothing to do with the OnTimer event).
              With a slight modification, it should work:
              Set the initial value of t_lpsd to 1 instead of zero:
              Code:
              if mod(t_lpsd.value,2)=0
              ..run your first script...
              else
              if mod(t_lpsd.value,3)=0
              ..run second script..
              end if
              t_lpsd.value=t_lpsd.value+1

              Comment


                #8
                Re: Is it possible to have more than one timer on a desktop form?

                Thanks Tom and Gabriel,

                After the initial curt reply, I wasn't expecting another response here. I will look at both suggestions.

                Thanks again :)

                Comment


                  #9
                  Re: Is it possible to have more than one timer on a desktop form?

                  Originally posted by G Gabriel View Post
                  Apologies. The script as written, I think and without testing it, will encounter a self-defeating timing issue (has nothing to do with the OnTimer event).
                  With a slight modification, it should work:
                  Set the initial value of t_lpsd to 1 instead of zero:
                  Code:
                  if mod(t_lpsd.value,2)=0
                  ..run your first script...
                  else
                  if mod(t_lpsd.value,3)=0
                  ..run second script..
                  end if
                  t_lpsd.value=t_lpsd.value+1
                  i have a concern about the mod logic:
                  this will work for the first round and my concern is what happens when t_lpsed_value id 5 then mod function will not return 0 so neither process will run defeating the original question that each process should run alternatively every 30 secs starting at 60 secs.

                  if the code is rewritten
                  set the last_run_process to 2
                  set the t_lpsed_value to 1
                  (probably on form activate event or some button onClick event)
                  then
                  Code:
                  if t_lpsed_value >=2 then
                     if last_run_process = 2 then
                         run process 1
                         last_run_process = 1
                    else
                         run process 2
                         last_run_process = 2
                    end if
                  end if
                  t_lpsd.value=t_lpsd.value+1
                  won't this work perpetually alternating processes skipping the first 30 sec interval?
                  Last edited by GGandhi; 11-11-2015, 07:17 AM. Reason: typographical error correction for value 2
                  thanks for reading

                  gandhi

                  version 11 3381 - 4096
                  mysql backend
                  http://www.alphawebprogramming.blogspot.com
                  [email protected]
                  Skype:[email protected]
                  1 914 924 5171

                  Comment


                    #10
                    Re: Is it possible to have more than one timer on a desktop form?

                    Govindan:
                    Your concern is legitimate.
                    Just modify the last line to:
                    Code:
                    if t_lpsd.value=3
                    t_psd.value=1
                    else
                    t_lpsd.value=t_lpsd.value+1
                    end if

                    Comment


                      #11
                      Re: Is it possible to have more than one timer on a desktop form?

                      Try something like the code below. You can vary it to fit your needs.

                      Set your timer interval on the form to 1, then...

                      Code:
                      dim vTime1 as N
                      dim vTime2 as N
                      
                      var->vTime1 = var->vTime1 + 1
                      IF var->vTime1 >= 60
                      	var->vTime1 = 0
                      	
                      	'Run your code here
                      END IF
                      
                      
                      var->vTime2 =  var->vTime2 + 1
                      
                      IF var->vTime2 >= 90
                      	var->vTime2 = 0
                      	
                      	'Run your code here
                      END IF

                      Comment


                        #12
                        Re: Is it possible to have more than one timer on a desktop form?

                        Thanks Scott, seems very straightforward - Does a timer running every second cause much of an overhead when you have folder content change watches running as well?

                        Comment


                          #13
                          Re: Is it possible to have more than one timer on a desktop form?

                          I do not use Folder Content Change so I cannot answer with any accuracy. I have most of my forms that I use like this set to a 1 second interval and some of the forms have 10-15 different timed events like the example and I do not have any negative performance impacts and our hardware is lower end stuff. When you set your timer interval really small it increases the overhead for sure but still no show stoppers that I have noticed. I have one form with a timer interval of .01 where the form is reading a scale via a serial port and do not have any issues.

                          Comment


                            #14
                            Re: Is it possible to have more than one timer on a desktop form?

                            Thanks again, will give it a try.

                            Comment


                              #15
                              Re: Is it possible to have more than one timer on a desktop form?

                              Originally posted by chortle View Post
                              Does a timer running every second cause much of an overhead when you have folder content change watches running as well?
                              That question was asked years ago, by me, in the form of a puzzler regarding OnTimer events in general. The answer as I see it, is no. But in this case, it's different, because the script has to update the value of these two variables every second not to mention whatever "watches" you were referring to. So in one minute, you run 60 scripts !!
                              If you want to go this route, you are better off with something like:
                              Code:
                              t1=now()
                              if now()-t1=>90
                              ..run your second script...
                              t1=now()
                              elseif now()-t1=>60
                              ..run first script..
                              end if

                              Comment

                              Working...
                              X