Skip to content
Sign upLog in
← Back to Community

`runBlocks()` function somehow not working

Profile icon
RixTheTyrunt

Can you please explain why is the runBlocks() function not converting blocks into JS? It is totally not working... AND EVEN NOT EXECUTING BUT INSTEAD LOGGING undefined!!!

Answered by SixBeeps [earned 5 cycles]
View Answer
Voters
Profile icon
RixTheTyrunt
Comments
hotnewtop
Profile icon
SixBeeps

The very first block you make has an ID of "block1". When you go to compile the script though, the very first block you check for is "block0" which never exists. You put this as the condition for your while loop, so it just bails and does nothing to the code variable.

Profile icon
RixTheTyrunt

But... It makes the counter into 1 and the searches for block1

Profile icon
RixTheTyrunt

See line 50:

blockCount += 1;

Profile icon
RixTheTyrunt

It's before line 49, which is:

while (document.getElementById("block" + blockCount) != null) { // While a block REALLY EXISTS...

Profile icon
RixTheTyrunt

OHHH I'M SOO DUMB

Profile icon
Matheus2722Q
Profile icon
MrVoo

You shouldn't be using eval()

Profile icon
RixTheTyrunt

THEN HOW SHOULD I EXECUTE THE CODE?!?!

Profile icon
SixBeeps

@RixTheTyrunt
Making your own interpreter is a much safer option.

Profile icon
RixTheTyrunt

But how?

Profile icon
RixTheTyrunt

How is that possible?