Sim Error: Calling non-function

I’m trying to work on a little editor to edit the multiple instruments on a song (based on @richard 's instrument editor). I’ve mostly figured out the internals of how the song format is represented and utilized, but I’m running into a strange simulator error that prevents the game from running.

To my knowledge, the function I’m calling should be valid which leaves me with not much to go with.

If anyone could give me any more information on how to debug this, it would be much appreciated!

Project file: https://makecode.com/_aXrMXkRFuVU7

1 Like

@SoCuul the problem here is just the ordering of your code, you’re calling the functions before they get defined.

Simply move the Main namespace under Util or use declared functions instead of assigning arrow functions to variables like you are right now

2 Likes

Found it! Your issue is that the outlined function is not defined when this code runs:


When I moved the Util namespace above Main, it worked! To debug, I used those game.splash() functions to tell if the game was really erroring at the point it claimed to be. Took a while to figure this one out because the error was being reported as being on the wrong line!

@makecode any idea why the error was being reported as occurring on the wrong line? The error was quite obviously not on that line!

P.S. this project looks super cool so far!! I hope you stick around here and share it when it’s done!

1 Like

Aah, can’t believe I didn’t notice that! Thanks for the help :smiley:

The error on the wrong line threw me off as well.