Inside WalkFolders( )Let's step through the WalkFolders function, line by line. It's a very short function, so it shouldn't take long!// ============================================
// walk through the folder, listing all files and descending into sub-folders
// calls fFolderNotify and fFileNotify functions
// ============================================
function WalkFolders ( oFolder, nLevel, fFolderNotify, fFileNotify )
{
var sName = oFolder.Name;
// skip test folders (start with _)
if ( sName.charAt ( 0 ) == '_' )
return;
// notify that we're in new folder
fFolderNotify ( oFolder, nLevel );
|
The first thing we do is to look at the Name property of the Folder object passed in. As a rule, I always skip anything that start with an underscore characters - that way I can always "hide" temporary test folders or files. The charAt( 0 ) method compares the first (zero-based) character to "_", and immediately exits the function if it matches. Next, because we are about to start looking through a new folder, we call the fFolderNotify function passed in. It's just called like a normal function, so you don't even have to bother with the awkward syntax used when de-referencing a function pointer in C (believe me, you don't want to know). The point to this is simple. Because the "client" who called this function passes in the functions to be called, they can re-use the WalkFolders( ) function for many purposes. Part 3: Walking through the files... |