FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   checking online/authoring mode
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: checking online/authoring mode  (Read 2224 times)
pollux

WWW Email
checking online/authoring mode
« on: Sep 3rd, 2003, 10:15pm »

toxi gave me an idea on how to check on-the-fly if an applet is online or in the processing environment:
 
Code:
// general vars
boolean authoring = true;
 
void setup() {
  size(200, 200);
  background(255);
  // etc...
  authoring = authoringMode();
}
 
// checking method
boolean authoringMode() {
  try {  
    String codeBase = getCodeBase().toString();
    return false;
  }  
  catch (Exception e) {  
    return true;
  }
}

 
hope it is useful for other people as it was for me...
 
[edit]
on the code posted before, i am just including the chunks of code that are actually involved on the issue...
« Last Edit: Sep 3rd, 2003, 10:18pm by pollux »  

pollux | www.frwrd.net
pollux

WWW Email
Re: checking online/authoring mode
« Reply #1 on: Sep 3rd, 2003, 10:19pm »

can somebody tell me why does getCodeBase() gives an error when called on runtime?
 

pollux | www.frwrd.net
fry

WWW
Re: checking online/authoring mode
« Reply #2 on: Sep 4th, 2003, 4:00am »

getCodeBase gets passed up to the applet context.. if it's in authoring mode, there is none. if it's in a browser, then the browser is supposed to supply it (and therefore will return something valid for getCodeBase()). p5 actually uses this trick internally to see if it's online or not (soon to be part of the api)
 
barikan

Email
Re: checking online/authoring mode
« Reply #3 on: Feb 29th, 2004, 5:59pm »

online() function is added with release 60:
http://processing.org/reference/online_.html
 
Pages: 1 

« Previous topic | Next topic »