It would be good to see that on the revDeveloper wiki or a place where comments can be made

The tutorial is obviously for beginner users and all efforts have been made to avoid any level of complexity. With these requirements, that's all good. The division into subroutines is well thought. The functions well commented.
However, a problem something to be careful about when learning to program is to learn good habits, even if this makes the learning a tiny bit more difficult. Habits are easier to learn than unlearn

I put a few comments... I welcome users of different levels of expertise to tell me what they think of them.
1) In terms of comments, the only reason to use local on top of each function is to make clear the variables that are being used within that function. Personally, I prefer to follow well accepted approaches to code commenting (javadoc and jsdoc). The advantage of this is that I can do automatic code parsing and automatically extract documentation for my code (jsdoc example). Another advantage is that you can more easily discuss your code with somebody from another programming background. Simply by reading the comments, they can understand what your program is about.
So the first function, for instance would become:
Code: Select all
/**
* Filters the strings "." and ".." from a list
* @param {list} pList. A list with one filename per line.
* @returns A filtered list
*/
function filterDots pList
[...]
end filterDots
Code: Select all
function filterDots pList
--- validation ----------------
if pList is empty then return empty
put pList into tList
--- processing ----------------
filter tList without "."
filter tList without ".."
---
return tList
end filterDots
Code: Select all
function listFiles pFolder, pRecurse
--- validation ----------------
if pFolder is empty then return empty --- you may want to let the user know that the folder is empty.
if there is not a folder pFolder then return empty -- you may want to warn the user that the folder doesn't exist
--- processing ----------------
set the directory to pFolder
[...]
end listFiles
Code: Select all
function listFiles pFolder, pRecurse
4) "if not then..." I see that construct in a lot of code within the community. Another version of this is a "if xxxx then" at the start of a function script with an "end if" at the very end of it. Even with indentation, this obscures the code. Then this forces you to keep in mind the limits under which the code is being applied all way through the function. Why not simply deal with the conditions under which the remaining of the function should or should not be applied and then simply completely forget about them. A minor comment is that a negation is always more difficult to process (cognitively speaking) than an affirmation.
Code: Select all
if tCurrentFiles is not empty then put tCurrentFiles & return after tTotalFiles
Code: Select all
--- condition of exit ------
if tCurrentFiles is empty then return empty
-----------------------
put tCurrentFiles & return after tTotalFiles