Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Could not figure out exactly what this code does
Message
From
03/06/2009 14:45:31
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01403230
Message ID:
01403478
Views:
51
This message has been marked as a message which has helped to the initial question of the thread.
2 Corrections inline - very easy - not tested

You can also apply the pattern to the individual SubFolderNames (two places to change)

May be a bit quicker - but less flexible


>You're right, sorry. It is just case-sensitive, I need case insensitive.
>
>I can make this change myself, though, it's not a problem.
>
>>Don't see the problem
>>
>>
>>SubFolders(@m.QueueObj, CURDIR(),  '*\Images\I*') 
>>
>>
>>
>>>Unfortunately, the directory to exclude is like 'Images\I*'
>>>
>>>FUNCTION RecursiveDirectoryList
>>>* Gregory Adam
>>>
>>>#define TRUE	.t.
>>>#define FALSE	.f.
>>>*-------------------------------------------------------------------------------
>>>local QueueObj, SubfolderName
>>>
>>>
>>>if( SubFolders(@m.QueueObj, CURDIR(), '*reports\_*') )
>>>
>>>	do while m.QueueObj.DeQueue(@m.SubfolderName)
>>>		?SubfolderName
>>>	enddo
>>>endif
>>>*-------------------------------------------------------------------------------
>>>function SubFolders(QueueObj, FolderName, FileSkeletonExclude)

                     FileSkeletonExclude = lower(evl(m.FileSkeletonExclude, ''))


>>>	local Success
>>>	Success = TRUE
>>>	
>>>	local StackObj, ColObj, SubfolderName
>>>	StackObj = createObject('Stack')
>>>	QueueObj = createobject('Queue')
>>>	ColObj = createObject('Queue')
>>>	
>>>	local fsObj
>>>	fsObj = createobject('Scripting.FileSystemObject')
>>>	
>>>	do case
>>>	case !m.Success
>>>	
>>>	otherwise
>>>		try
>>>			objSubFolders = m.fsObj.GetFolder(m.FolderName).SubFolders
>>>		
>>>		catch
>>>			assert FALSE
>>>			Success = FALSE
>>>		
>>>		endtry
>>>	
>>>	endcase
>>>	
>>>	
>>>	do case
>>>	case !m.Success
>>>	
>>>	otherwise
>>>		for each Subfolder in m.objSubFolders 
>>>			=m.ColObj.EnQueue(m.Subfolder.Path)
>>>		endfor
>>>		
>>>	endcase
>>>
>>>	do while m.Success ;
>>>			and m.StackObj.AppendFrom(m.ColObj, TRUE) ;
>>>			and m.ColObj.Clear() ;
>>>			and m.StackObj.Pop(@m.SubfolderName)
>>>		



		if( !empty(m.FileSkeletonExclude) and like(m.FileSkeletonExclude, lower(m.SubfolderName)) )


>>>			loop
>>>		endif
>>>		
>>>		=m.QueueObj.EnQueue(m.SubfolderName)
>>>		
>>>		objSubFolders = m.fsObj.GetFolder(m.SubfolderName).SubFolders
>>>		
>>>		for each Subfolder in m.objSubFolders 
>>>			=m.ColObj.EnQueue(m.Subfolder.Path)
>>>		endfor
>>>		
>>>	
>>>	enddo
>>>	
>>>	
>>>	return m.Success
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>*-------------------------------------------------------------------------------
>>>*===============================================================================
>>>*===============================================================================
>>>*===============================================================================
>>>define class Stack as CollectionBase
>>>
>>>*-------------------------------------------------------------------------------
>>>function Push(v)
>>>	=m.this.Add(m.v)
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>function Pop(v)
>>>	
>>>	if( empty(m.this.Count) )
>>>		return FALSE
>>>	endif
>>>	v = m.this.Item(m.this.Count)
>>>	=m.this.Remove(m.this.Count)
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>function Peek(v)
>>>	
>>>	if( empty(m.this.Count) )
>>>		return FALSE
>>>	endif
>>>	v = m.this.Item(m.this.Count)
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>*-------------------------------------------------------------------------------
>>>enddefine
>>>*===============================================================================
>>>*===============================================================================
>>>*===============================================================================
>>>
>>>
>>>*===============================================================================
>>>*===============================================================================
>>>*===============================================================================
>>>define class Queue as CollectionBase
>>>
>>>*-------------------------------------------------------------------------------
>>>function EnQueue(v)
>>>	=m.this.Add(m.v)
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>function DeQueue(v)
>>>	
>>>	if( empty(m.this.Count) )
>>>		return FALSE
>>>	endif
>>>	v = m.this.Item(1)
>>>	=m.this.Remove(1)
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>function Peek(v)
>>>	
>>>	if( empty(m.this.Count) )
>>>		return FALSE
>>>	endif
>>>	v = m.this.Item(1)
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>enddefine
>>>*===============================================================================
>>>*===============================================================================
>>>*===============================================================================
>>>
>>>*===============================================================================
>>>*===============================================================================
>>>*===============================================================================
>>>define class CollectionBase as Collection
>>>
>>>*-------------------------------------------------------------------------------
>>>function Clear()
>>>	
>>>	=m.this.Remove(-1)
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>function Empty()
>>>
>>>	return empty(m.this.Count)
>>>	
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>function AppendFrom(ColObj, Reversed)
>>>	
>>>	local i
>>>	
>>>	do case
>>>	case !m.Reversed
>>>		for i = 1 to m.ColObj.Count
>>>			=m.this.Add(m.ColObj.Item[m.i])
>>>		endfor
>>>	
>>>	otherwise
>>>		for i = m.ColObj.Count to 1 step -1
>>>			=m.this.Add(m.ColObj.Item[m.i])
>>>		endfor
>>>	
>>>	
>>>	endcase
>>>	
>>>
>>>endfunc
>>>*-------------------------------------------------------------------------------
>>>enddefine
>>>
>>>
>>>>Easy it is
>>>>(1) add an optional parameter
>>>>(2) Skip the like(parameter)
>>>>
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform