Thanks Andy. For some reason the Dim handling code removed the declared variable before running the inner code. Will be fixed in the next update.
I'm sure that you know the workaround, but for other users :
B4X:
Sub MakeSprite(num)
len = ArrayLen(data())
Dim data(len)
End Sub