what is pRecurse

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
theowright2020
Posts: 7
Joined: Tue Jan 21, 2020 11:50 pm

what is pRecurse

Post by theowright2020 » Wed Jan 22, 2020 4:48 pm

can anyone clarify what pRecurse would represent as a parameter within a function?

' ' '

# Returns a list of files in a given folder, using recursion to
# include files in subfolders if desired.
function listFiles pFolder, pRecurse
local tTotalFiles, tCurrentFiles, tFolders

set the defaultFolder to pFolder
put filteredFiles() into tCurrentFiles

if not pRecurse then
return tCurrentFiles
end if

if tCurrentFiles is not empty then
put tCurrentFiles & return after tTotalFiles
end if

## Now the recursion
## We call listFiles passing a subfolder as an argument
put filteredFolders() into tFolders
repeat for each line tFolder in tFolders
put listFiles((pFolder & slash & tFolder), pRecurse) into tCurrentFiles
if tCurrentFiles is not empty then
put tCurrentFiles & return after tTotalFiles
end if
end repeat
delete the last char of tTotalFiles

return tTotalFiles
end listFiles

' ' '

this is copied from the livecode website, for recursively accessing embedded folders and files

however, I am unsure of what I actually need to pass into the function as the pRecurse parameter, is it a boolean??

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: what is pRecurse

Post by dunbarx » Wed Jan 22, 2020 5:37 pm

Hi.

pRecurse is a variable, passed as a parameter in the original function call.

Not sure about the context at all, but the line:

Code: Select all

if not pRecurse then 
is the same as:

Code: Select all

if pRecurse = "false" then 
Craig

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: what is pRecurse

Post by jmburnod » Wed Jan 22, 2020 6:12 pm

Hi,
the pRecurse parameter, is it a boolean??
Yes pRecurse is a boolean you have just to set it to true or false.
BUT
I tested this script with LC 9.5.0 and it doesn't work
I think filteredFolders and filteredfiles function are missing
Is there anyone who know "filteredFolders" function ?
Best regards
Jean-Marc
https://alternatic.ch

Post Reply