run 10 jobs in random order within another one

MDM

  • Joined: Jul 8, 2011
  • Posts: 38

Mon 8/22/2011 - 3:57

hi,
I just spent a few hours trying to complete a job... but i got totally stuck.

here's what I want to do.
i want to run 10 jobs in random order and call a few other actions (which i dont mention here in order to keep it simple) between each of the 10 jobs.

example:

- start
- load a list with the 10 names of the jobs from a textfile
- shuffle the list
- run the first job of the shuffled list
- run some other  actions
- run the second job from the shuffled list
- run some other  actions
- run the third job from the shuffled list
.... and so on.. until all 10 are done.

it would be awesome if anyone could tell me how to accomplis this or point me to a similar example job that will help me figure out the solution on my own.
 

#1

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Tue 8/23/2011 - 17:27

Hi MDM, please check the job attached. It should give you an idea as per how you can implement what you're after. Please note that you shall see the index starting from 0 to 9 instead of 10. It's due to the fact that lists are 0 based in WinAutomation. :) Samantha

Running Jobs in random order.waj

#2

MDM

  • Joined: Jul 8, 2011
  • Posts: 38

Wed 8/24/2011 - 14:41

Hello Samantha,

 

thank you VERY much for your kind help.

To be quite honest, I don't fully understand it by now....  mainly because of the "advanced" configuration of the commands.  for example the placement of the  brackets in the following line.

WinAutomationController /start "%Jobs[Random[1]]" 

if i am correct, it means the first line of the variable named "random" inside the "jobs" variable.

 

my main problem is, that i cannot find anything about those advanced topics in the manual. for example i never would have figured out on my own how to use the brackeets in this case and the numbering. although the fact that a list starts at zero and not at 1 is mentioned in the manual - and you also reminded me on that in yesterdays post ; )

 

where can i find the required documentation to understand these things better? so that i am not so much dependant on help from others.

 

one more question about the actual task...   the 10 jobs that i want to call are actually WA jobs, so I thought I would have to use the "run job" command. I guess I confused you because i was saying that I want to load the job names from an external list.   the reason for this is as follows.  this task is indended to become an easy to modify "template" - so in case i want to use it for a similar purpose, but with different named jobs i thought it would be a lot easier to just edit a txt file instead of all the 10 entries inside the main job itself.

 

so to sum it up for now...  will the example that you gave me still work if i use "run job" instead of "rund dos command"      and     where can i find the advanced documentation?   

 

oh, and one last thing....   on the main WA webpage and also in the manual i noticed that "nesting" was mentioned several times and that it is such a great thing....   but i couldn't find any further explanation about that either.    did i just miss it?   if you know any link or place where these things are explained a bit more in detail please let me know. 

 

THANK YOU : )    your kind assistance is very much appreciated!

 

#3

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Wed 8/24/2011 - 15:11

Hello! I'm glad the job worked for you! To be honest, the information is all spread accross the Forum and cookbook and Knowledge base. However, if you do post any questions here about anything you do not understand, we'll gladly post a reply and help you figure things out. There are also a couple of Webinars posted, as well as quite a few Video Tutorials that will help you get a lot of info as per how you can get things done. Regarding the bracketing system.. well.. The things has as follows: Each variable is of some specific type. And each type of variable allows you to grab some specific values. For example, list type variables have a ".Count" property, and you can also grab any item of the list, by specifying in brackets the index of the item you want to retrieve. If the item of the list is a text type property, then you can grab its ".Length" by typing: %List[0].Length% %List[0]% is no longer a list type property but a text type property and you can use the text type properties to define what you want from the list's item. Samewise, you can use variables to define the index of the item. So.. if we used the Random Number generator and defined that we want a list of random numbers, we can then access each randon number from the list, by specifying, as above, the item we want. So.. %RandomNumber[0]% would give us the first item of the Random Numbers list, so the value of this would be a number. We can use this number to define the item of the list we previously used: %List[RandomNumber[0]]% which means that we want to grab the item of the text list found at row %RandomNumber[0]% which is the first item of our random numbers list. Hope this all makes sense. Samewise you can use combinations of variable properties to get various values from one variable alone. eg. a datetime variable (Eg. %Now% is the result of a "Get Date Time" action) will give you a full date and time, but you can also retrieve the name of the day, as well as the length of the name of the day: %Now% = 24-08-2011 18:10:00 %Now.DayOfWeek% = Wednesday %Now.DayOfWeek.Length% = 9 :) Samantha

#4

MDM

  • Joined: Jul 8, 2011
  • Posts: 38

Thu 8/25/2011 - 13:10

Hello Samantha,

 

I think you missed something in my previous post....   probablyi was writing too much ; )

the question was if the provided solution would also work for actual "jobs" and not for external programs.  tonight i already figured out by myself, that it does in fact not work with jobs.

i was confusing you because i was mentioning the external list with the job names that i want to load. the reason for this list is simple.   from my main job i want to call 10 jobs in a random order. on the next day for example i want to run the same main job again... but this time with 10 different random jobs. lets say for example i have 50 jobs and each day i want to run 10 jobs out of the 50 but in a random order. a few weeks later the list might have increased already to 70 available jobs.

in order to keep it simple and not having to modify the main job each day i want to only modifiy the list in the textfile. this would be the fastest solution i think,  do you know what i mean?    since the 1st solution that you suggested seems to work only for external programs (i did not find a way how to put a variable into the "job to run" action input) - can you think of a different solution that will work with jobs rathen than external programs?

 

 

also.... thank you very much for the throrough explanation of the  bracketing system. It all makes sense this way. 

 

I still think it would be a VERY good idea to compile all the advanced information which is related to this and put it into a section of the manual.  

Similar to the action reference, where each action is briefly explained.  Likewise each advanced command and alteration should be at least mentioned once by name.

The reason why i suggest this is simple.   you said this information is spread around in the forums, cookbook etc.    this is good and useful. but only as long as a user knows what he is looking for. since I do not know what to ask for I cannot use the search...  and posting a question on the board is just too slow in most cases, especially since many problems cannot be solved with the first answer it might take days until one problem is solved.... eventhough the responserate on this board is FAR above average - thanks to your great efforts ; )      if i know for example that a bracketing system exists and if i know just a little bit about what it is used for, i can search the forums - because i know the search term.   this way around, it makes it alot easier, at least for me ; )

I had a feeling that those commands and terms are not WA exclusive and probably are used in a similar way like regular expressions can be used. in which case an "external" documantation would exist

 

EDIT: after trying some more to figure out a way to do the "run job" actions in a random order I still couldn't find a way that works. I had all kinds of solutions in mind...  for example using the clipboard for the names. But I always get stuck where I need to put in the name of the job. Since it seems that it only can be chosen manually from the dropdown list right inside the properties window and not otherwise.  Do you have another idea?

#5

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Thu 8/25/2011 - 16:35

Hi there, well actually what i suggested does work for exe files as well as jobs created and stored in winautomation's database. You can check out this post here to get a better idea of what i'm talking about: http://www.winautomation.com/cookbook/i-want-controll-winautomation-jobs-running-and-stoping-using-command-line :) Samantha

#6

MDM

  • Joined: Jul 8, 2011
  • Posts: 38

Thu 8/25/2011 - 16:46

thank you  : )

 

#7

MDM

  • Joined: Jul 8, 2011
  • Posts: 38

Thu 8/25/2011 - 22:30

hmmm.....    after examining the link with the solution more thorough i noticed that this is basically the same solution like the one you were using already in the first example.

 

while it actually DOES run there is still a huge difference (please correct me if i'm wrong) I still cannot activate "wait for job to complete" which is vital in my case since between each call some actions are called - like in the first example. this is why i was asking once again after the first one. or is it maybe possible with a special commandline parameter?

 

I also need to know it the job completed successfully, but the exception of the dos command only applies for the command itself, not the the program it called, right?

 

 

#8

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Fri 8/26/2011 - 10:00

what you could do, is tell it to wait for the notification window named after the job to close. else have as a last action, a message box named completed, which is the window you should be waiting to appear in all jobs. If it has not completed successfully you could then display a message window "not completed" and define the job's course according to that! :) Samantha

#9

MDM

  • Joined: Jul 8, 2011
  • Posts: 38

Fri 8/26/2011 - 13:33

Great Idea Samantha! I this has got to work perfectly   

I probably should have figured this on my onw by now - after spending so much time on it ; )

 

In the mean time one more question came up.  Is there a way I can "read" a variable from a different job which is already finished? 

I was already trying it with the persistent flag, but it seems that it is bound to the job itself, not to the name of the variable, right?  in other words... if i flag a %TestValue% variable to be persistent inside a job called "test one" and the job is finished, I can read the value of the variable the nex time the "test one" job is executed, but not if I make any other job with a %TextValue% variable.

how can I store a variable of a finished job and read it in another job.    and also, how could i pass variables around from job to job while they are still open?   

 

 

 

 

 

 

#10

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Fri 8/26/2011 - 13:51

You could write that value in a text file and read it from the second job :) Samantha

#11
Not a member yet? Register

Copyright 2013 - Softomotive Ltd