Is there a way to determine what mode the sketch is using in runtime?

edited October 2016 in JavaScript Mode

I have two functions that read a file, but each only works for Java or JavaScript respectively. It would be nice if I can figure out what mode the sketch is running in so that I can use the right function for the environment. I know this may seem weird, but I'm just doing it for debugging purposes at the moment. I find it's much easier to debug in Java because its performance is much better. Thanks!

Answers

  • static final boolean IS_PJS = 1/2 == 1/2.;

  • Answer ✓

    the above uses integer division.

    in java 1/2 will be 0 because of integer division, 1/2. (note the .) is .5, so they will be different.

    in javascript they will be the same.

  • HA! Not what I was expecting as an answer but very clever. Thanks guys!

Sign In or Register to comment.