Array of Arrays in a while!

hi guys, i’m a new OpenHab user and i’m trying to add some arrays in an arrayin my rule. The problem is that if i try it in a “while cycle” it doesn’t work. idk how to do this.
Here is the code:

var ArrayList <ArrayList> sched = newArrayList ()
var i = -1
while((i=i+1) < l1) {
	//extraction from the file json of the data
	var String startD = transform("JSONPATH", "$.Medicaments["+i+"].treatment.start", json)
	var String endD = transform("JSONPATH", "$.Medicaments["+i+"].treatment.end", json)
	var String stepD = transform("JSONPATH", "$.Medicaments["+i+"].treatment.step", json)
    val String nameM = transform("JSONPATH", "$.Medicaments["+i+"].name", json)
	val String IdM = transform("JSONPATH", "$.Medicaments["+i+"].id", json)
	val String dosM = transform("JSONPATH", "$.Medicaments["+i+"].dosaggio", json)

	var String ogni1 = stepD.substring(5, 6)
	
	var s = newArrayList()   //I create the new array wich we have to insert in the array "sche"
	var Number k = 0

           // this is just a control if we had the data yet
	sched.forEach[somm |
		var ArrayList <String> som = somm
		if (som.get(0)== idM && som.get(1)==dosM && som.get(2)==ogni1) {
			som.add(startD)
			som.add(endD)
			k=1
			break
		}
		k=0
	]
	 if (k== 0) {          //HERE WE INSERT DATA IN S , THE ARRAY TO INSERT IN SCHE
		s.add(ogni1)
		s.add("0")
		s.add(startD)
		s.add(endD) 
		//sche.add(t)        **THIS COMMAND DOENS'T WORK IN THE WHILE**
	}

}

I saw that the command sche.add(s) works if i’m out of the while. I would like to know a way to do this work.
thank you

while((i=i+1) < l1) {

l1 isn’t a number

t isn’t defined anywhere. You can’t add a variable that doesn’t exist to an ArrayList.

Do you see errors in the log?

In order to reference a variable inside a forEach I think it needs to be final. Declare your ArrayLists as val. You can still modify the list even if it’s final, you just can’t assign a different list to the same variable later.

Yes, sure, my bad.
I just didn’t want to write all the code but the variables are declared yet. (exept the “t” that was an “s”, i didn’t paste and copy and that’s the result).

Otherwise i don’t know if it’s a problem of declaration since the code runs with no problem if I delate "“sche.add(s)” (when i try to add a vector in the vector) so this linecode is the problem).

And do you get an error in the logs on that line? Errors contain useful information that one can use to understand what went wrong. A lack of error can also be informative but then the follow up is how do you know the line doesn’t work?

I usually use to check the values of some items displayed on the HABpannel: if the valute chances that means that the rule is correct, otherwise there’s a problem.
In the log I see non errors if u mean the log inside userdata/logs/event.log.

I’m Sorry for the late reply.

No, you will never see errors in events.log. Errors will appear in openhab.log.

I just tried the rule with the
sche.add(t)
The rule doesn’t work on the HabPannel because it doesn’t display the value setted in the rule.
I opened the path: openHAB\userdata\logs\openhab.log but it is empty, with no messages.

that’s a problem unto itself. Unless you turned it off there is always stuff logged to openhab.log. You will not be able to since the outlet with your rule without the error logs so you need to figure that out first.