Iterating a Variable

Post here if you need help using Actiona
Post Reply
klawncare
Posts: 1
Joined: 15 Nov 2019, 16:18

Iterating a Variable

Post by klawncare » 15 Nov 2019, 16:26

OK, so, I've got a script that is copying data from one program to another, since no decent export option is available.

So, it is running through the data, line by line, each time we loop through the script.
However, the program that I'm copying data from doesn't "remain open" so that I can simply have the script "move down a line" to grab the next line of data. Each time, the program has to be re-opened.

Each time, upon reopening the program, the script must "down arrow" all the way to the next line to be copied, which means, each time we loop through the script, it must move one more line down than the last time.

Currently, the only way I can seem to make this work is to "ask" the user on each loop, which line to access. So, each time through the script, the user must enter a number one greater than the last, hit enter, and we loop through again.

Obviously, this is silly and unnecessary. Currently, I am saving that data that the user enters into a variable, and then using the value of that variable to tell the script how many lines to move down for the next copy iteration.

How do I manage to simply have the user provide the "start" number, but then have the script iterate that variable on each run-through, before looping back and restarting the process?

At present, the variable is set at beginning of the script with the current/beginning line number. I want to "reset" that variable to the beginning number + 1 at the end of the script run and then loop back and run the script again with the new variable value. How do I do it?

eureka
Posts: 87
Joined: 08 Mar 2016, 22:18

Re: Iterating a Variable

Post by eureka » 15 Nov 2019, 17:43

Difficult to understand the workflow. I would try to copy the content in one go to avoid multiple opening of application but it seems that you cannot do this.

But if you wish to key the “arrow down” a variable number of times I would

create a Code object at the beginning to set a variable
set var linecount=1
in the Key object ("arrow down") set Amount field to be the variable "linecount"
increment the variable “linecount” after each line copy
loop back using Loop object.

The important step as I see it is to introduce your linecount as variable in the Key amount field.

stifler
Posts: 12
Joined: 29 Oct 2019, 08:51

Re: Iterating a Variable

Post by stifler » 16 Nov 2019, 00:24

In javascript you can just use ++, or you can do it traditionally;


var x = 0;
Console.print (x); // Returns 0
x++
Console.print (x) // Returns 1
x = x + 1;
Console.print (x) // Returns 2

Post Reply