|
Post by kokenge on Mar 6, 2008 9:17:39 GMT -5
I call a JavaScript function that runs a backend (server) RunBasic process that gets real time information and displays graphs and video on the Front. However if I change the BackEnd program, it still runs the old program. Actually sometimes its random and will run the new program. This is a avionics program and it reads gauges, gps, and other data, links it up to online maps and displays to the panel. The user has input and buttons to do other request while the backend is pulsed every second.
To get it to always run the new program I have to stop Run Basic, and the Browser and start it again.
What am I doing wrong? How do I get it to run the new code when I change it?
Thanks for the help
|
|
|
Post by Jerry Muelver on Mar 6, 2008 9:39:20 GMT -5
What happens if you force the browser to refresh when testing the app after making changes? It could simply be running the old version from cache.
|
|
|
Post by kokenge on Mar 6, 2008 9:45:30 GMT -5
Tried that. It's even stranger than that. I changed a fixed value I display for test. Changed it from displaying "A" to "B". Sometimes the old value "A" shows up and sometimes the new "B" shows up. This is even after a refresh.
|
|
|
Post by kokenge on Mar 6, 2008 10:18:31 GMT -5
Ok! I think I figured out a workaround. If you call a Backend Program the same way as the last time it will somehow run the program that it first ran with that command. Howeve if you pass it a variable such as "1" and "2", if "1" ran the program that displayed a "A" will always run that program even thought you have new code. If it ran "B" with parameter "2" it will run that program. If you now pass "1" again it will run the old code.
I changed the program to pass the seconds since midnight back and forth. Now each run looks unique. It has nothing to associate with, so it runs the new code. This should be good for a day, and hopefully no one does cache that long.
Someone is doing cache, and it associates the program with the way it was called???
|
|
|
Post by carlgundel on Mar 6, 2008 13:49:37 GMT -5
Ok! I think I figured out a workaround. If you call a Backend Program the same way as the last time it will somehow run the program that it first ran with that command. Howeve if you pass it a variable such as "1" and "2", if "1" ran the program that displayed a "A" will always run that program even thought you have new code. If it ran "B" with parameter "2" it will run that program. If you now pass "1" again it will run the old code. I changed the program to pass the seconds since midnight back and forth. Now each run looks unique. It has nothing to associate with, so it runs the new code. This should be good for a day, and hopefully no one does cache that long. Someone is doing cache, and it associates the program with the way it was called??? Are you sure your browser isn't caching a page? Run BASIC doesn't cache the last compile of a program. -Carl
|
|
|
Post by carlgundel on Mar 6, 2008 14:22:01 GMT -5
After rereading your post, I must say I don't really understand what your program does. Could you please describe it in some more detail?
-Carl
|
|
|
Post by kokenge on Mar 6, 2008 14:32:37 GMT -5
No not sure. It's very confusing. Here is the test. 1. I have a backend program that passes a fixed field "A" 2. I run a RB program that passes a value using the "&" separator as &1. 3. It returns the "A" 4. I change the backend program to return a fixed field "B" instead of "A" 5. I call the backend program with JavaScript that still passes &1. 6. It returns "A" even though the backend has been changed to return a "B". 7. I now call the Front end with a different pass as &2. 8. The backend returns a "B" like it should. 9. If I change the Frontend to pass the 1 again as "&1", I get the "A" back. And that is the old program. 10. If I change the front to pass "&3" or "& anything but 1" it will return "B". 11. If I call it passing "&3" it will return the B. 12. Now if I change the Backend to pass a "C", when I call it with "&1" I get "A" returned, If I use "&2" or &3" I get a "B" returned, If I use "&4", I get the new "C" returned.
Somehow it remembers how it was called and returns, or runs the program that matches the call.
So I figured if I pass a new variable each time, like "& + seconds since midnight" it wouldn't have anything matching in the call, for a day anyway.
And believe it or not - this works.
I've done Refresh while it's running, and that don't seem to help.
I really do want it to cache, because I pass graphics from the backend that is repeated. So I'd like it to use previous graphics if possible.
Is this confusing enough?
Have a great day...
|
|
|
Post by turbov21 on Mar 6, 2008 14:57:56 GMT -5
That sounds like the browser caching pages. I tried to use RBP to do something similar with an early version of ToDo, but a second RBP program wouldn't properly handle the JavaScript requests. The only thing I could figure was that, since JavaScript calls happen in the same browser, somewhere between the browser cache and RBP's session data, the browser wasn't acknowledging what RBP was serving.
|
|
|
Post by turbov21 on Mar 6, 2008 15:13:14 GMT -5
EDIT: I am assuming this is essentially what you want, an HTML interface from one RBP app that gets simple back-end changes from another RBP app. If not, please excuse my posts. Okay...well, now this works: AjaxText1html "<script type=""text/javascript"" src=""http://kerovia.net/js/jquery-1.2.1.js""></script> <script type=""text/javascript"">
function getData(el) { $.get(""/seaside/go/runbasicpersonal"", {app: ""AjaxTest2"", name: el.value}, function(data) { document.getElementById(""woopydo"").innerHTML = data; }); }
</script> <p> <span id=""woopydo""></span> <input type=""button"" value=""Andy"" onclick=""getData(this);"" /> <input type=""button"" value=""Roxy"" onclick=""getData(this);"" /> </p>" AjaxTest2raw GetVal$(UrlKeys$, "name")
' Grabs a value from the url function GetVal$(string$, key$) value$ = "" key$ = key$ + "=" startit = instr(string$, key$)
if startit > 0 then startit = startit + len(key$)
endit = instr(string$, "&", startit)
if endit > 0 then endit = endit - startit value$ = mid$(string$, startit, endit) else value$ = mid$(string$, startit, len(string$)) end if end if GetVal$ = value$ end function
|
|
|
Post by kokenge on Mar 6, 2008 18:51:01 GMT -5
Yep! Exactly what I'm doing. I have a javaScript program that runs other programs. My javaScript is a little more general but does the same thing. You supply this routine with the following: 1. The backend program name to run. 2. Values seperated by & If the value is a changeable value such as <input> <checkboxes> etc you supply the value between bars like &|ts| 3. The backend can give raw data back that will fill any number of fields on your screen by supplying field name and value separated by a bar "|"
So if the Front End has
html "<TABLE>" html "<TD><INPUT TYPE='TEXT' id='ts' SIZE=20 onChange=""server('http://localhost:8008/seaside/go/runbasicpersonal?app=avionicsBe&Evnt&1&|ts|');"">" html "</td></tr><tr><TD>" html "<INPUT TYPE=BUTTON id='go' Value='Disp' onCLick=""server('http://localhost:8008/seaside/go/runbasicpersonal?app=avionicsBe&Disp&2&|ts|');"">" html "</td></tr><tr><TD>" html "<INPUT TYPE=BUTTON id='go1' Value='Test' onCLick=""server('http://localhost:8008/seaside/go/runbasicpersonal?app=avionicsBe&Test&3&|ts|');"">" html "</td></TR></TABLE>"
In this case the first <input text field with id=ts,, when changed runs a Backend program called 'AvionicsBe' and passes the following values 1.Evnt 2. 1 3. whatever you changed in "ts" since it has bars "|" around it
If you click the Disp Button it runs the same 'AvionicsBe' program and passes the following. 1. Disp 2. 2 3. The value in the "ts" Input text area.
The backend program Avionics gives "raw" data back separated by bars "|" Each bar supplies the ID to display to, and the value The backend returns: a$ = "ts|";time$("seconds");"|" ' plus other areas| and data| raw a$
However if I don't pass the unique time in area "ts" back and forth it will run old code.
There is a little more going on such as a timer firing the backend every second.
The javaScript
' --------------------------------------- ' Backend communications ' --------------------------------------- html " <script language=""javascript""> <!--
function createRequestObject() { var ro; var browser = navigator.appName; if(browser == ""Microsoft Internet Explorer"") { ro = new ActiveXObject(""Microsoft.XMLHTTP""); } else { ro = new XMLHttpRequest(); } return ro; }
var http = createRequestObject();
function trim(string) { while (string.substring(0,1) == ' ') { string = string.substring(1, string.length); } while (string.substring(string.length-1, string.length) == ' ') { string = string.substring(0,string.length-1); } return string; }
function handleResponse() { if(http.readyState == 4) { var response = http.responseText; //alert ('got back from server response:' + response); var at = 0; // --- strip leading junk ---- x = response.substring(0,1); while (x < '0') { response = response.substring(1); x = response.substring(0,1); } var update = new Array(); if(response.indexOf('|' != -1)) { update = response.split('|'); x = update.length; // alert ('update length:' + x); for (i=0;i<x;i++) { update[i] = update[i].replace(/;;/g ,'|'); } for (i=1;i<x;i=i+2) { at = i - 1; update[at] = trim(update[at]); // alert ('at:' + at + '|update[at]:' + update[at] + '|i:' + i + '|update[i]:' + update[i]); try { ss = document.getElementById(update[at]); ssv = ss.value; sse = ss.element; sst = ss.title; ssn = ss.name; ssi = ss.id; ssh = ss.innerHTML; // alert ('ss:' + ss + '|ssv:' + ssv + '|sse:' + sse + '|ssn:' + ssn + '|ssi:' + ssi + '|ssh:' + ssh + '|at:' + update[at] + '|i:' + update[i] ); if (ssv != undefined) ss.value = update[i]; else if (ssh != undefined) ss.innerHTML = update[i]; } catch(err) { alert ('Invalid display field:' + update[at]); } } } } }
function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""""); } function server(prog) { prog = ltrim(prog); // Left trim rs = http.readyState; // see if the previous task it done - state must be 0 if (rs == 4) rs = 0; if (rs != 0) { rs = 0; try { rs = http.readyState; // see if the previous task is done - state must be 0 } catch(err) { rs = 1; alert ('Server Busy. Please try again. Thank you and have a nice day ' + rs); } } if (rs == 0) { prog1 = ''; xx = ''; if(prog.indexOf('|' != -1)) { val = prog.split('|'); for ( key in val) { // alert('key:' + key + ' |val:' + val[key]); x = ''; xx = val[key]; if (key & 1) { try { x = document.getElementById(xx).value; toe = document.getElementById(xx).type; // type of element chk = document.getElementById(xx).checked; prog1 = prog1 + x; } catch(err) { // alert ('--error----xx:' + xx + '|err:' + err.description); prog1 = prog1 + err.description; } // alert ('------x:' + x + '| toe:' + toe + '| chk:' + chk); } else prog1 = prog1 + xx; } } //alert ('server side get program| prog1:' + prog1); http.open('get', prog1); http.onreadystatechange = handleResponse; http.send(null); } }
//--></script> "
|
|
|
Post by zoomkat on Mar 6, 2008 23:35:08 GMT -5
You might try adding a long string of randomly generated characters to the passed data, then discard them when the data is actually used.
|
|