PrateekSaxena Posted March 15, 2007 Author Share Posted March 15, 2007 @justsomeguy : Well the variable does not have any onchange event! So will I have to stick with the Trace or should I put an update button on the Watch section or make it reload every 5 seconds or something like that? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 15, 2007 Share Posted March 15, 2007 That's what you could do, just use settimeout to have it update the values every second or something like that. That will be good enough, you will just need to keep a list of variable names, and use the eval function to get the values to print out.About the errors, it only displays the first fatal error. When it reaches a fatal error, such as an undefined function, it cannot continue to execute, it just doesn't know how to continue. That missing thing might have been vital for something later in the code, so if it is missing then execution has to stop at that point, the program state is no longer stable enough to continue. That's just the nature of fatal errors, you'll see the same thing with syntax errors in PHP. It wouldn't make sense to report 50 syntax errors if the first error is causing all the others, so the first error is reported and then the code gets reevaluated after that error gets fixed. Link to comment Share on other sites More sharing options...
PrateekSaxena Posted March 16, 2007 Author Share Posted March 16, 2007 But is introduces (yet) another problem because the if the variable that was passed was a local one then on timeout I will not be able to get its value. I could save the function.callee in the array too and then try to get it....will this be possible? Link to comment Share on other sites More sharing options...
aspnetguy Posted March 16, 2007 Share Posted March 16, 2007 I was thinking about this last night and I am unsure how you will accomplish this, perhaps you may need to get the user to iniitalize and array when they setup the console and pass in what variables they want to watch. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 19, 2007 Share Posted March 19, 2007 Aren't Javascript variables inherently global? It shouldn't be a probem to access them through the timeout handler. All you need is an array of variable names. varwatch[0] = "var1";varwatch[1] = "var2";varwatch[2] = "var3";function settimeout_handler(){ document.getElementById("watch").innerHTML = ""; for(i = 0; i < varwatch.length; i++) { eval("document.getElementById(\"watch\").innerHTML += \"" + varwatch[i] + ": \" + " + varwatch[i] + ";"); }} Link to comment Share on other sites More sharing options...
aspnetguy Posted March 19, 2007 Share Posted March 19, 2007 exactly, it would require the programmer to setup to watch array to monitor their variables. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 19, 2007 Share Posted March 19, 2007 There could be a function that adds an element to the array. function addWatch(varname){ varwatch.push(varname);} The programmer would have to say which variables they want to watch, but I don't think that's anything new. It would be nice if you could get a list of all of the declared variables, I'm not sure if that can be done or not. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now