We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Loading the URL into Processing
Page Index Toggle Pages: 1
Loading the URL into Processing (Read 783 times)
Loading the URL into Processing
Sep 30th, 2006, 8:56pm
 
Hi - I'm trying to make a simple processing applet that will "visualize" an entered number.  So for example, if the user enters 5, then 5 boxes (or some other object) will be displayed.

I'm trying to make the number entry happen in an HTML form, and then I'd like my embedded processing applet to be able to pull in the data.  The HTML form sticks the entered value into the url.  So, for example, when 5 is entered, the URL reads:

file:///Users/tpower/Desktop/ok.html?n=5

What I'm having trouble with is some how loading the URL of the current page.  I know this can be done with Java using

getDocumentBase()

and I'm wondering how I can do this in processing.  Also, , once the URL is loaded, I'll have to pull out just the n=5 part.  Any suggestions would be greatly appreciated!
Re: Loading the URL into Processing
Reply #1 - Sep 30th, 2006, 9:57pm
 
One solution would be to use applet parameters.  This is done with a <PARAM> tag between the <APPLET> and </APPLET> tags.

   <APPLET CODE=myApplet.class>
   <PARAM NAME="parameterName" VALUE="paramValue">
   </APPLET>

You can then retrieve the parameters with the getParameter method.

Code:

String param = getParameter("parameterName");
int num = int(param);


You can set the parameter dynamically with php, etc.  

Code:

<? $val= $_GET['val']; ?>

<param name="paraName" value="<? if (isset($val)) { echo $val; }?>">
Re: Loading the URL into Processing
Reply #2 - Oct 1st, 2006, 5:42am
 
Great, thanks!  That did the trick.
Page Index Toggle Pages: 1