I have a Processing program that I update by running this method:
public void createParam (int nWidth, int nHeight, int nNumBalls, float[] nR, float[] nVel, int[] nC)...
I can do this through Javascript pretty easily as long as I don't try to change the last three values:
var applet = document.getElementById("ballApplet");
applet.createParam(divw, divh, 6, null, null, null);
This works perfectly.
However, I'm trying to use C# to accomplish this with non-null values. I'm using this code:
string command = "var applet = document.getElementById('ballApplet'); ";
command = command + "applet.createParam(divw, divh," + numBalls + ", " + r + ", " + vel + ", " + c + ");"; //width, height, num, radius, vel, c
JCall(command);
num is an int, radius and vel are float arrays, and c is an int array.
JCall is a method I use to add Javascript to a page. It's not important to this problem and it works as intended.
This results in the Javascript error:
Error: syntax error
Source file: http://localhost:63803/Default.aspx
Line: 1227, Column: 214
Source code:
var applet = document.getElementById('ballApplet');
applet.createParam(divw, divh,1, System.Single[], System.Single[], System.Int32[]);
It seems like it's passing the type (System.Single[]) rather than the array itself. How do I pass the array to Javascript?
Update: To be a bit more explicit, there's three pieces of code here.
C#, that calls a JavaScript function.
JavaScript, that calls a method in a Processing applet.
Java, a Processing applet that has the "createParam" method.
Here is how the relevent variables are declared in C#:
int numBalls = eventCount;
...
float[] vel = new float[numBalls];
...
float[] r = new float[numBalls];
int[] c = new int[numBalls];