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

How to run several scripts at different intervals

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

    How to run several scripts at different intervals

    I have not done anything on the desktop side with Alpha yet so totally new to me. I want to create a simple work queue processor using the runtime. This work queue processor has to check if emails need to be sent every 5 seconds, needs to read some xml every hour etc. I found this code in the wiki but I can't figure out how to set multiple timers:

    Code:
    dim log as c = ""
    dim dlg_title as c
    dim dlg_body as c
    dim dlg_event as c
    dlg_title = "Schedule"
    dlg_body = <<%dlg%
    {timer=playScript}
    {interval=5}
    This dialog will run another script called 'script1' every x seconds.;
    The interval can be changed by editing the {{interval} command.;
    {lf};
    
    Event Log:;
    [%M%.100,20log];
    <Close>;
    %dlg%
    dlg_event = <<%code%
    if a_dlg_button = "playScript" then
    script_play("script1")
    log = "Last execution: " + now() + crlf() + log
    end if
    
    if a_dlg_button = "Close" then
    ui_modeless_dlg_close(dlg_title)
    end if
    %code%
    ui_modeless_dlg_box(dlg_title,dlg_body,dlg_event)
    
    Here is 'script1':
    
    'this is script 1
    'put your code here that you want to run every x minutes.
    dir_create_recurse("c:\eventLog")
    save_to_file("Script executed at: " + now() + crlf(),"c:\eventLog\events.txt",.t.)
    My idea is to save the main script as "autoexec" so that it fires when the runtime launches.

    I would also like to have a "are you sure?" confirmation dialog instead of a simple close button that immediately closes the dialog.

    Any help appreciated!
    Frank

    Tell me and I'll forget; show me and I may remember; involve me and I'll understand

    #2
    Re: How to run several scripts at different intervals

    I did not gather exactly what you are doing, but grasped the idea of running a lot of scripts. Suggest you sdave each script that might comflict with another one into UDF's and run them in the order you need from a script with a wait for idle in between them as needed.

    Scripts do tend to run over each other.

    UI_msg_box() or one of the others should suffice for the question. You can trap the vars and use them to say stop or go as needed.

    Oh, Don't hesitste to let the genies make the message boxes and stuff, them turn them to code so you can modify as needed. Much quicker and more exact.

    Comment


      #3
      Re: How to run several scripts at different intervals

      Frank
      I dont think I would use Xdialog method to run multiple tasks at varying times. Unless I was very advanced in XDs
      Design suggestions;
      Were it me I would follow the line of creating a form for each task. Each using an ontimer event (as long as you don't need split second accuracy)
      You could size and position each form to look like a control dashboard each reflecting the activities.
      OR a form with multiple browses reflecting the necessary log-lists and the form would have to be set at the highest timer rate.

      Also could look at script_schedule which allows up to 10 timers, but that would require resetting to NEXT run time after each event is run.
      Al C it's usually more useful to offer advice if you do actually gather what the question is.

      Comment


        #4
        Re: How to run several scripts at different intervals

        What does work rather nicely and easily, is to use that sample dialog, and for each process create another with a different title and different timer.
        Call them all in one sequence.
        I just tested it out. It functions perfectly.
        Then create a script with the sequence to close them all when done for the day or whenever.
        Last edited by Ray in Capetown; 08-31-2013, 04:10 AM.

        Comment


          #5
          Re: How to run several scripts at different intervals

          Hi Frank, nice to see you come into the DT space. We "spoke" when I came across from Clipper myself some years back.

          I have tested the following method using the xdialog code you have, and it does as you want..
          ..Duplicate the code for each process you want to schedule, name each accordingly, changing at least the dlg_title, script and interval.
          ..Call each from a menu or form or whatever.
          You can remove the CLOSE button and have ui_modeless_dlg_close(dlg_title) close the XD in the calling code or form, to control closing each.

          Muuuch easier than doing it all in one and allows arranging them into a dashboard layout.

          Al C, strange you can still give advice even though you "did not gather" the question asked.

          Comment


            #6
            Re: How to run several scripts at different intervals

            Ray,

            Thx! Clipper, Funcky (remember that lib ?) was sort of fun but Alpha really is fun!

            I ended up defining a global variable 'counter', the script that fires every 5 seconds increments 'counter' & in that script I check if MOD(counter,12)=0 for stuff that only needs to run every minute (5secs x 12) and so on. Every hour I reset the counter to 0 to avoid overflow. The script also begins with a check for a boolean 'scriptbusy' , if the script is busy (from a previous call) the I don't execute it to prevent stack overflows etc.
            Frank

            Tell me and I'll forget; show me and I may remember; involve me and I'll understand

            Comment


              #7
              Re: How to run several scripts at different intervals

              I think you only need the one form and the one timer if you can set the logical flow correctly.

              Timer fires every five seconds.
              Checks to see if emails need to be sent.
              If the minutes of the current time are 00 and logical variable for having read xml is false, top of the hour, read the xml and set the logical to true. If the minutes are 59, set the logical back to false.
              Etc.

              Just another approach.
              There can be only one.

              Comment


                #8
                Re: How to run several scripts at different intervals

                Sounds like a good solution. I also came from clipper many years ago.

                Comment


                  #9
                  Re: How to run several scripts at different intervals

                  Just for fun try this out, it will take less than ten minutes.
                  3 changes to each xdialog
                  Xdlg scriptname:::Xtimer1::::::::Xtimer2:::
                  dlg_title = ::::::::::"X1":::::::::::"X2"
                  :::::::::::::::::::::{interval=5}:::{interval=40}
                  script_play:::::::("onerun")::::::("tworun")

                  Launch each of these using script play("xtimer1") and script play("xtimer2")
                  separate the two dialogs on the screen and you have a potential dashboard of activity

                  I think it's a very slick UI. Add more tasks in minutes.

                  Comment


                    #10
                    Re: How to run several scripts at different intervals

                    Also take a look at script_schedule()
                    Peter
                    AlphaBase Solutions, LLC

                    [email protected]
                    https://www.alphabasesolutions.com


                    Comment


                      #11
                      Re: How to run several scripts at different intervals

                      Haven't been looking at the forum lately so this is a bit late but maybe someone else can use the idea. Note also that xdialogs can be hidden. I've hidden them and closed them with a timer but haven't tried running multiple timer actions with hidden dialogs so it's just conjecture but it should work. That would allow you to run them as timers without them being in the way of anything else. You then might want to use something like ui_modeless_dlg_exist() to check for their existence before allowing the app to close.

                      Comment

                      Working...
                      X