Subj : Re: Problem using JS Objects and JS Objects implementing Java Interfaces To : Alvaro Diaz From : Igor Bukanov Date : Wed Apr 30 2003 02:59 pm Alvaro Diaz wrote: > I wrote a function for reading the contents of a directory recursively. > But the result of calling the function (contained in variable root) is undefined. > Can somebody help me out ? > > function Directory( path) > { > var directories = new Array(); > var files = new Array(); > > var directoryFilter = new java.io.FilenameFilter() > { > > accept:function( dir, name) > { > if( new java.io.File( dir, name).isDirectory()) > directories.push( [name, Directory( path + "/" + name)]); > else > files.push( name); > } > } > > new java.io.File( path).list( directoryFilter); > > directories.sort(); > files.sort(); > > return this; > } > > var root = Directory( "."); Are you sure that root contains undefined? You code for Directory function has no other side effects then function Directory( path) { return this; } var root = Directory( "."); and that should put the current scope object to root, not undefined. Regards, Igor .