Here's my theory... According to something I saw through a google search, a null returned in a function call makes a variable assignment fail.
Therefore doing something like x=nullFunct(); and trying to use x after null is returned will throw a coldfusion.runtime.UndefinedVariableException instance. However, he wasn't doing an assignment but just calling the function inline, so the behavior being dependended upon never fired, causing an infinite loop. Could you try the code I sent and see if it works? -dov -----Original Message----- From: Rob [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 02, 2005 6:05 PM To: CF-Talk Subject: Re: CFC / Java file reader help. It's probably: do { outputStr = outputStr & variables.bufferedReader.readLine() & chr(13) & chr(10); } while (true); you need to break that loop somehow - that is an endless loop. You'll probably want to either check readline for null or eof and break out of the loop, or have some other kind of conditional in that while that does not always evaluate to true On 8/2/05, Ian Skinner <[EMAIL PROTECTED]> wrote: > Can somebody point out the obvious and show me why this code is creating an endless loop. I have this CFC that is supposed to read a file using java file reader objects. For some reason my call to the "readAll()" function causes an endless loop. > > <cfcomponent> > <cfscript> > variables.fileReader = ""; > variables.bufferedReader = ""; > </cfscript> > > <cffunction name="init" access="public" returntype="javaFile" output="false"> > <cfargument name="file" type="string" required="true"> > > <cfscript> > variables.fileReader = createObject("java", "java.io.FileReader"); > variables.fileReader.init(arguments.file); > > variables.bufferedReader = createObject("java", "java.io.BufferedReader"); > variables.bufferedReader.init(fileReader); > </cfscript> > > <cfreturn this> > </cffunction> > > <cffunction name="readAll" access="public" returntype="string"> > <cfscript> > var outputStr = ""; > > try { > do { > outputStr = outputStr & variables.bufferedReader.readLine() & chr(13) & chr(10); > } while (true); > } catch (coldfusion.runtime.UndefinedVariableException e) { > // this indicates end of file, ok to ignore error > } > </cfscript> > > <cfreturn outputStr> > </cffunction> > </cfcomponent> > > It is being called from a template such as this. > > <cfsilent> > <cfflush interval="1000"> > > <cfif structKeyExists(form, "upFile")> > <cfset javaFileObj = createObject("component","javaFile").init(form.upFile)> > </cfif> > > </cfsilent><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" > "http://www.w3.org/TR/html4/strict.dtd"> > <html> > <head> > <title>File Upload</title> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> > </head> > > <body> > > <cfif structKeyExists(variables, "javaFileObj")> > <cfdump var="#javaFileObj#"> > <cfoutput>#javaFileObj.readAll()#</cfoutput> > </cfif> > > <cfoutput> > <form > action="#cgi.script_name#" > method="post" > enctype="multipart/form-data"> > > <input type="file" name="upFile"> > <input type="submit"> > </form> > </cfoutput> > </body> > </html> > > -------------- > Ian Skinner > Web Programmer > BloodSource > www.BloodSource.org > Sacramento, CA > > "C code. C code run. Run code run. Please!" > - Cynthia Dunning > > Confidentiality Notice: This message including any attachments is for > the sole use of the intended > recipient(s) and may contain confidential and privileged information. > Any unauthorized review, use, disclosure or distribution is > prohibited. If you are not the intended recipient, please contact the > sender and delete any copies of this message. > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:213545 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

