RobberBaron Posted February 24, 2010 Share Posted February 24, 2010 1): I have a code that waits for an argument to be true: function waitFor(event){ if (!event) { return false; waitFor(event); } else { return true; }} It has a "warning": JSC_UNREACHABLE_CODE: unreachable code at line 34 character 2 waitFor(event); ^ Can anybody help?2): My code here: function newSender(jname, jtarg){ jname=new Object(); jname.title=jname.tostring(); jname.event="System.Targets.Events.EXCode;"; jname.arg=System.Targets.Arguments.UI(); jname.target=jtarg; jname.send=function() { tbSend=newAction('/document.stp?g=get&hash=true#' + this.target + '); tbForm=__sendPostData(this.event, this.arg); tbForm.action=tbSend; tbForm.submit(); } return jname;} The errors are in the method send (jname.send=function()): JSC_PARSE_ERROR: Parse error. unterminated string literal at line 28 character 73 tbSend=newAction('/document.stp?g=get&hash=true#' + this.target + '); ^JSC_PARSE_ERROR: Parse error. missing ) after argument list at line 29 character 11 tbForm=__sendPostData(this.event, this.arg); ^JSC_PARSE_ERROR: Parse error. syntax error at line 29 character 12 tbForm=__sendPostData(this.event, this.arg); ^ Some help?3): Final problem, this has decided to not let my for loop work. Code: function update(){ timer=Response.Get('timeDiv'); if (timer) { inter=Response.Get('innerCenter'); if (inter) { nowTime=timer.Text; editable=inter.Text; for (i=-10, i<0, i++) { var mills=i*100; setTimeout('temp.Text=Now()', mills); } } }} Errors: JSC_PARSE_ERROR: Parse error. missing; after for-loop initializer at line 11 character 24 for (i=-10, i<0, i++) ^JSC_PARSE_ERROR: Parse error. syntax error at line 18 character 1 Sorry, a lot to ask, but can anyone help? Link to comment Share on other sites More sharing options...
jeffman Posted February 24, 2010 Share Posted February 24, 2010 If you closely examine the source code of a standalone GUI application, you will find an infinite loop; with every iteration, the presence of an event is tested. That's how those environments work.A browser environment is a different thing.In a browser environment, the infinite loop operates behind the scenes. We do not create infinite loops to wait for events. We create event listeners, and the DOM will execute the listener when the event occurs. An infinite loop will take 100% control of a browser, and cause every browser to put up a warning after 30 seconds or so. There is no JavaScript/DOM equivalent to the wait() or sleep() command found in other languages and environments.Recursive function calling is still permitted, but will be interrupted if it goes on too long. (If the interpreter thinks it is infinite.) Timers can be created using setInterval and setTimeout. These allow code to be executed at intervals without hijacking the runtime environment.I hope that addresses some of your issues. Link to comment Share on other sites More sharing options...
jeffman Posted February 24, 2010 Share Posted February 24, 2010 tbSend=newAction('/document.stp?g=get&hash=true#' + this.target + ');The final quotation mark opens a string, but the string is never closed by a matching quotation mark. You're not even adding any string after the final + sign, so I don't know why you need it. Anyway, that error probably causes the errors in the lines that follow. Link to comment Share on other sites More sharing options...
jeffman Posted February 24, 2010 Share Posted February 24, 2010 JavaScript constructs for-loops with semicolons ( ; ) as the delimiter, not commas. Commas can be used to delimit multiple statements within the first and third elements of a loop definition, but they cannot delimit elements from each other. Link to comment Share on other sites More sharing options...
RobberBaron Posted February 24, 2010 Author Share Posted February 24, 2010 JavaScript constructs for-loops with semicolons ( ; ) as the delimiter, not commas. Commas can be used to delimit multiple statements within the first and third elements of a loop definition, but they cannot delimit elements from each other.Thanks. I wanted to wait until I sorted these errors before I uploaded my site to the internet. Everything is fixed now Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.