Re: Move files based on filename string matches?

From: J French (erewhon_at_nowhere.com)
Date: 03/08/04


Date: Mon, 8 Mar 2004 09:36:54 +0000 (UTC)

On Sun, 7 Mar 2004 14:24:37 -0500, "Rick Rothstein"
<rickNOSPAMnews@NOSPAMcomcast.net> wrote:

<snip>

>>
>> On balance, I reckon it is better to break things down into small
>> discrete tasks - it makes code simpler to follow
>
>Something like this maybe (where I did not list the non-moved files)?

<snip>

While that would work fine, no, that is not how I would code it
(although much of the same code would be there)

I would have something rather like this :-

Private Type TCMN
     SrcPath As String
     FoundItems() As SomeUDT
     KeyWords() As String
     ...
End Type

Private cmn As TCMN

Private Sub LS_SetupControl( Er As Boolean )
     Dim A() As String

     Call LS_GetKeyWords( cmn.KeyWords() )

     ' --- Generic Routine
     Call GS_ReadFilesToArray( cmn.SrcPath + "*.*", A$(), Er )
     If Er Then Exit Sub ' Fatal Error

     Call LS_ArrayToFoundItems( A$(), cmn.FoundItems() )

     ' --- Local Routine, can work on multiple 'data arrays'
     Call LS_ProcessKeyWords( cmn.KeyWords(), cmn.FoundItems() )

     ' ---- Initial Display
     Call LS_PopulateUserSelectionDisplay( "", cmn.FoundItems() )

     ' ---- Hand over control to User selection GUI
End Sub

Notice that I'm deliberately passing module level variables into local
routines.

What I'm trying to say is that mostly I don't care /how/ something is
done - just that a routine gets an input, and provides an output

- whether GS_ReadFilesToArray( FileSpec$, A$(), Er )
 uses Dir() or FindFirst/FindNext is not relevant to the App

- where the KeyWords() come from, and how they are extracted is of
total irrelevance

I think you need to look at this :-

          If Not FileExists(Directory & Group(X).Keyword) Then
            MkDir Directory & Group(X).Keyword
          End If

IMO FileExists() and DirExists() should be different contructs

The problem with 'heavy' routines is that one's eye is taken off the
minute details
- for example how should one handle the case where a file of the same
name exists in the SrcPath and the DestPath ?

 



Relevant Pages

  • Re: Move files based on filename string matches?
    ... KeyWordsAs String ... Private Sub LS_SetupControl ... The problem with 'heavy' routines is that one's eye is taken off the ...
    (microsoft.public.vb.enterprise)
  • Re: Move files based on filename string matches?
    ... KeyWordsAs String ... Private Sub LS_SetupControl ... The problem with 'heavy' routines is that one's eye is taken off the ...
    (microsoft.public.vb.enterprise)
  • Re: qr and subroutines
    ... [SNIP] ... Your $tmp_regex is not a regex, ... I shouldn't have referred to the string as "regex", ... sub rework_uri { ...
    (comp.lang.perl.misc)
  • RE: Text box values in user forms
    ... Here are the two routines, one is straight from a book I have that I would ... Dim sText As String ... Sub StartSig() ... Public sTextFill As String ...
    (microsoft.public.word.vba.beginners)
  • Re: The Philosophy of Programming?
    ... less trivial to ensure that the string length has not been altered. ... > lowers psychological complexity for most intelligent readers. ... For most intelligent programmers, the laziness principal applies. ...
    (comp.programming)