loading
 
Dual Camera, working on dual controls in Web
Dgephri from United States  [23 posts]
16 year
tried altering the Index.html page in notepad thus:
<table>
<tr><td colspan=2 align=center>
<applet width=640 height=240 code="RoboRealm.class">
<param name="timeout" value="0">
<param name="authorization" value="[authorization]">
</applet>
</td></tr>
</tr>
<tr>
  <td colspan=1 align=center>
    <input type="button" value="UP   -1" onclick="setVariable('move1 = 1')">
  </td>
  <td colspan=1 align=center>
    <input type="button" value="UP   -2" onclick="setVariable('move2 = 1')">
  </td>
</tr>
<tr>
  <td colspan=1 align=center>
    <input type="button" value="  LEFT  -1" onclick="setVariable('move1 = 4')">
    <input type="button" value="RIGHT-1" onclick="setVariable('move1 = 8')">
  </td>
  <td colspan=1 align=center>
    <input type="button" value="  LEFT  -2" onclick="setVariable('move2 = 4')">
    <input type="button" value="RIGHT-2" onclick="setVariable('move2 = 8')">
  </td>
</tr>
<tr>
  <td colspan=1 align=center>
    <input type="button" value="DWN-1" onclick="setVariable('move1 = 2')">
  </td>
  <td colspan=1 align=center>
    <input type="button" value="DWN-2" onclick="setVariable('move2 = 2')">
  </td>
</tr>
</table>
using the RR file below.  Goal is to control two laser pointers in the field of vision of the Mosaic output to Webserver.  When I hit any of the buttons on the Index.html pages, it locks up IE7 and no input is changing in Watch Variables of RR.  I thought I just copied and pasted hoping renaming the variables and changing VBScript would work...must have missed something.
program.robo
Anonymous 16 year
You appear to be missing the Javascript code at the top that has the setVariable routine. If that is missing IE will not know how to send back the request to RoboRealm correctly.

Also note that in some cases spaces are important. I'd remove the spaces in the move1 = 4 cases to move1=4 just to be sure that RoboRealm does not interpret that value as a string.

Note that if you want to rename the variable that get sent to RoboRealm you have to change the move1=4 to something like move_new_1=4 Just changing the value="xxx" in the HTML changes the way the page displays the buttons but does NOT change the name of the variable that is sent back to RoboRealm.

STeven.
Dgephri from United States  [23 posts] 16 year
I only pasted the changes I made, the original top code to Index.html is still:
<script language="Javascript">
function setVariable(cmd)
{
  var xmlDoc;
  var isIE;

  try
  {
    xmlDoc = new XMLHttpRequest();
    isIE = false;
  }
  catch (e)
  {
    xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
    isIE = true;
  }

  if (xmlDoc==null)
  {
    alert('Browser XMLHttp create error!');
    return;
  }

  xmlDoc.open("GET", "/set_variables?"+cmd, false);
  // prevent caching
  if (isIE)
    xmlDoc.setRequestHeader("If-Modified-Since:","Tue, 11 Jul 2000 18:23:51 GMT");
  xmlDoc.setRequestHeader("Accept","text/html");
  xmlDoc.send("");

  if (xmlDoc.responseText!='ok')
    alert("Error setting variable!");
}
</script>
I did try removing the spaces, with no changes, but if something else is the problem, spaces wouldn't show a fix yet I guess.

Name of variable: Did I set them up in RR file properly?  I don't need to send NEW variables, just new VALUES.  Is my RR file ok?
Dgephri from United States  [23 posts] 16 year
Variable: I think, after reading your post 6-7 times, I finally see what you are saying...the HTML knows the button text is different, but doesn't know to send "move1" and "move2", when the original script is for just "move"?
Anonymous 16 year
That's correct. Because we are using AJAX in the page (i.e. using Javascript to send back urls to the webserver without refreshing the page) the normal HTML names don't really apply here. What does apply are the statements in the Javascript function call in the onclick function. Thus if you want to change what is sent back to the webserver you have to change the name=value inside the onclick call instead of the HTML.

You can switch everything to a regular HTML form post but that would require the page to reload on every click and cause a slowdown in the video streaming since the applet would need to be reloaded and reconnected. Using AJAX helps to keep the interactivity of the page usable at the cost of increased complexity.

STeven.
Anonymous 16 year
so if I change them to "move1_new" it should work in sending the variable "move1" changes?
Dgephri from United States  [23 posts] 16 year
sorry about anonymous post, didn't input my user info.
I tried changing the Onclick call to:
<input type="button" value="UP   -1" onclick="setVariable('move_new_1 = 1')">

and I still get the same lack of variable change.  Changed the VBScripts in my RR file to all the same "move_new_1" and "move_new_2" as well.  Forgive my noobishness, really trying to figure it out so I can get it worked out and proceed with movement ranges and such.
program.robo
Anonymous 16 year
You have to remove those spaces. We added a check for this in the Webserver code to prevent this issue from happening again ... in your line above you are creating a variable

"move_new_1 " with value " 1"

Note the space after the variable and before the value. It should read

<input type="button" value="UP   -1" onclick="setVariable('move_new_1=1')">

i.e. delete the spaces ... they just pollute the variable name and its value.

STeven.
Dgephri from United States  [23 posts] 16 year
thanks, I will give that a try.  I missed those spaces entirely.  :(

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index