Page 1 of 1

Scrip loop: for (i=0; i<128;i++) does not bang enoght?

Posted: 09 May 2017 19:35
by Perun
Hello,

I noted that sometimes the Script code (OnLoad) does not bang the loop completely.
In my case I do have not too long code. There are several short loops which load some data I need for the final purpose.
For example I want to set "label_off" and "label_on" or more tasks within a loop of 128 buttons in one go using a loop i<=128.
I'm sure that the loop is ok, however buttons 0-81 are only named (for example) etc. If I delete the "label_on" row, then the loop names 100 buttons for example.
Here is a part of the code.

Image

The "Mnms" array does not load the names as expected.
I have noted that loop problem in other codes as well.
It seems that the loop is not strong enough?

QUESTION: Is there any wait/time trick to make that working, or I have to split that "act" code into several ones, using expressions or any other alternatives?

Thanks in advance.

Re: Scrip loop: for (i=0; i<128;i++) does not bang enoght?

Posted: 10 May 2017 20:42
by RichG
[edit: Revising my answer because I missed where your said this was an 'OnLoad' issue.]

Can you attach the file? Tough to diagnose with just a little snippet of code.

I'm assuming 'm' is being initialized properly somewhere? Where is the script? Is it at the very top level of the project?

First guess is it's taking too long for the loop to execute and something else is interrupting it.

Not sure if this will work, but it might be worth a try...

Define a variable called trigger, then set your script to run when trigger changes.

Then in your project initialization (OnLoad), set SomeName.trigger = 1. That will force the script to run.