Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Neat trick for code testing

IgnatzIgnatz Mod
edited July 2013 in General Posts: 5,396

Suppose you have a function, and you think of a different approach that might be better, but you need to test it. You don't want to mess up the function you have, so you first create a copy with a different name, to keep it safe, and then mess with the code.

There's a neater way to do this, if you do it a lot. Create an extra tab on the right called (say) "Test". Make a copy of your function in there (keep the name the same). Mess with the code. Run it. When Codea compiles your code (from left to right), it will compile both copies of the function, but the Test copy will overwrite the original function because its tab is to the right and gets compiled later, so it will be used instead.

This enables you simply to put copy any function into your Test tab and play with it, then delete it when you're done, keeping your original code very clean.


  • edited July 2013 Posts: 499

    you could copy the function just down below the original and have the same effect., since the compilation goes from top to bottom inside the document...

  • IgnatzIgnatz Mod
    edited July 2013 Posts: 5,396

    True! As long as you don't get confused and edit the wrong one! Which is the sort of thing I have done before when I have two versions too close together.

  • Posts: 499

    also true)))

  • Posts: 391

    Nice, this is good to know. I just ran into this problem about an hour ago when editing my auto-tile algorithm. I totally butchered my original function and thought I screwed myself, but good thing I had a complete copy saved in emails, hehe.

  • BriarfoxBriarfox Mod
    Posts: 1,542

    Nice tip, I've never considered doing that.

Sign In or Register to comment.