In the spiral print CRX tutorial, is it necessary to use dir variable

I mean even if dir variable is not used the will will be worked fine. why to use dir variable.

No, it is not necessary to use dir variable.