Script?

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Script?

Post by plasticmagnet » 29 Jul 2014 21:33

Hii,
I want to add upcounting numbers to an other variable. im using a for-loop...

code:
s = "something";
firstNumber = 1;
lastNumber = 10000;
currentNumber = 0;
list = newList();

for (currentNumber in [firstNumber to lastNumber])
{ addElement(list, s + currentNumber); log(s + currentNumber)
}


Now how to do it if value lastNumber > 10000?
On my device it throws error somewhere after 10000.

Anyone an idea?

Note: tested while-loop with same result.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Script?

Post by Martin » 30 Jul 2014 18:27

Hi,

There's an artificial limit to stop loops at 10000 iterations.
You could split the loop into multiple sequential loops, nesting loops should also work.

Code: Select all

for(i in [i to 10000])
{
   for(n in [1 to 10])
   {
   }
}
What are you trying to achieve? Creating lists with hundreds of thousands of entries might result in out of memory problems at some point.

Regards,
Martin

plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Re: Script?

Post by plasticmagnet » 30 Jul 2014 21:26

I'm working on a little yahoo tool and need to create a .txt file that contains a list of numbered user names..

user1
user2
user3
user4
user5
...
.
user10001
user10002
..

I think with your code it creates a list from 1 to 10000 then starts over again?

plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Re: Script?

Post by plasticmagnet » 31 Jul 2014 16:57

Even though im understanding the loop inside a loop i keep ending up in an infinity loop.

Any help is much appriciated.

plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Re: Script?

Post by plasticmagnet » 01 Aug 2014 06:17

:)

s = "something";
list = ([1 to 10100]);
list = replaceAll(replace(replace(list=s+list, "[", ""), "]", "") ,"\\,\\s","\n\{s}");
log(list);

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Script?

Post by Martin » 01 Aug 2014 06:23

I would probably create a flow that generates 10000 users at once appends the users to file and then generates the next 10000 users. The flow could repeat this process as many times as you like.
This procedure has the advantage that you can control the amount of used memory and don't need to generate tens of thousands of usernames into a list variable.

Flow Generate Usernames (please adjust the file in action Write to File)

The example generates 10 times 000 users. The current user id is stored in variable id which is incremented in the for-loop every time a user is added to the list.
The action Write to File uses the append option so it will append the same usernames again when you run the flow multiple times.

I also like your solution, which is much simpler :-) (it might cause memory problems when "something" and/or the list is very long)

plasticmagnet
Posts: 19
Joined: 14 Sep 2013 18:41

Re: Script?

Post by plasticmagnet » 01 Aug 2014 07:07

Thanks sir,

I had something like that too, but found it was too slow. And too much code. Anyway, Thanks for this sweet app and for your time!

Gruß!

Post Reply