This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Ash Adamson
Posted Sep 17 - Read on Facebook

Getting a really weird error when trying to run a function that changes background color of a layer inside an array.

Works fine without the else statement, breaks when I add the else.

Anyone know how to go about debugging this? Really annoying because the error is thrown but code still works.

5 Comments

Sigurd Tapio Mannsåker

Could it be that days[i] doesn't exist for certain values of i that don't pass the if statement?

Sigurd Tapio Mannsåker

Ah, you probably meant to add another dot to 0...days.length. With two dots it's inclusive, while with three it stops one before so you don't go past the end of the array.

Ash Adamson

That fixed it! One dot means all the difference, so amazing. Thank you!!!

Koen Bok

IndexErrors are the worst :-/

Sigurd Tapio Mannsåker

Happy to help :) As a side note, you could avoid the whole issue by doing something like this:

for day, i in days
_if firstDateLoc < i and i <= d
__day.backgroundColor="#22ADF6"
_else
__day.backgroundColor="white"

Handy syntax so you don't need to set the day variable to days[i] manually.

Read the entire post on Facebook