Reset Loop Counter if Procedure is called.

Post here if you need help using Actiona
Post Reply
Pancholin
Posts: 1
Joined: 14 Jul 2020, 21:57

Reset Loop Counter if Procedure is called.

Post by Pancholin »

Note: I am reposting this thread that I previously deleted since I thought I fixed it but clearly I didn't

Hello, it's no secret that Actiona is accessible to people like me who wants to automate things but have no experience in programming whatsoever, so I might need a little help over here:

Sometimes the software am trying automate locks down or crashes at random times and it's very very hard to determine if the program it's locked or isn't, here's how my current workflow looks like:

Image

They're a bunch of 'Find Image' that call procedures if they get a hit. What I am trying to do is so if a procedure is called the loop counter for Line 15 resets to a certain value (in this case 10), for example: if any Find Image gets a hit on loop 4 out of 10, it resets the counter for Line 15 back to 10, if 10 loops happens with no match, it continues to Line 16 (that line reset the software that's locked), then loops back to the first loop that contains all the Find Image.

Already tried to set the loop counter from Line 15 to a variable that resets at the end of every procedure (procedure does its thing and as a last step it sets a variable to 10, then goes back to Line 1), but that's clearly not how that works since the first loop counter retains its original value and proceeds to Line 16 after 10 loops, even if a procedure was called.

So I am a bit lost :? would appreciate any insight since I have zero experience in coding. Thanks!
eureka
Posts: 204
Joined: 08 Mar 2016, 22:18

Re: Reset Loop Counter if Procedure is called.

Post by eureka »

I do not have a clue what you are attempting to do but I suspect that you could make it easier if you learn some ECMAscript. You appear to be navigating some app Window.

When I develop an automation script to manage a workflow I ask myself these design questions first.
Is this just for my personal use or do I have to consider different screen sizes and operating systems?
If the script is for my personal use (not others) I know that I need not concern myself about different target positions or screen sizes. And I always maximise window before targetting.

I can usually define these targets by variables such as

key strokes
menu navigation
context menus
x:y coordinates

and not by using images which can be tricky to setup and are subjective. Images are my last resort and I rarely need them.

Another point is your use of line number for your loops. I advise not to use line numbers since it is easy to get your objects out of sequence. For example you might insert a Console object to help tracing. This would break your calls to line numbers. Instead Call procedures (not line numbers) or even change the target line number to labels.

...

If you can master how to write arrays in a Code object this will help your workflow.

First browse through some Actionscript guides.
Here is one relevant section.

https://docstore.mik.ua/orelly/web2/action/ch08_01.htm

Now you can use the code editor in Actiona but I find that the code is easier to read in an external editor.

Here is just one (there are several to choose from but Sublime Text comes with an Actionscript package out of the box).


Choose a block of script to try in Actiona code object.

var i = 3;
while (i < 5) {
Console.print("x is less than 5");
i++;
}

Important to note that Actiona uses "Console.print" instead of "trace"

After the Code object place a Console object which simply prints values of "i".

Use Code objects to test various Actionscript snippets. Then you can approach your requirement.

I would define for each step an array with routes to take at each action point. You would only have one object for image targetting and not multiple actions as you have. Just iterate through the arrays to pickup the variables. It is worth spending time learning some code.
Post Reply