• Hi,

    There isn't a way of doing this in 2v08 (short of modifying every app to make it declare what it is).

    However I have just added something I have been meaning to do for a while, which is to make the load(filename) function write the file that has just been loaded into a variable. So if you load a cutting edge build, you can now do:

    function getAppType() {
      if (!global.__FILE__) return "clock";
      if (!__FILE__.endsWith(".app.js")) return "app";
      var j = require("Storage").readJSON(__FILE__.sli­ce(0,-7)+".info",1);
      return (j&&j.type)||"app";

    So __FILE__ will be the file that has been loaded, however in the default app case (eg load() or long-press BTN3) it'll just be undefined, since no file was supplied.

    So actually if you just want to run this only for the default clock, you can check global.__FILE__===undefined. However in that case if you then explicitly run it from the launcher, __FILE__ will end up getting set.


Avatar for Gordon @Gordon started