GetFileList not reporting as expected

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
BlackCat
Newbie
Posts: 13
Joined: Mon Dec 20, 2010 12:32 am

GetFileList not reporting as expected

Post by BlackCat » Sat Jan 22, 2011 1:40 am

I'm trying to use GetFileList to check if any files are contained within a folder. This test code works when run as its own script:

Code: Select all

GoSub>VerifyFilesPresent1
SRT>VerifyFilesPresent1
GetFileList>D:\BlackCats_Documents\My_Videos\DVD\Adventure\MovieFolder1\VIDEO_TS\*,files
MessageModal>files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
    If>file_names_count>0
        MessageModal>Has files
    Else
        MessageModal>Doesn't have files
    GoSub>Exit_Script
    Endif
END>VerifyFilesPresent1

SRT>Exit_Script
  Exit
END>Exit_Script

MessageModal>Start of Second Verification
GoSub>VerifyFilesPresent2

SRT>VerifyFilesPresent2
    GetFileList>D:\BlackCats_Documents\My_Videos\DVD\Test\MovieFolder2\VIDEO_TS\*,VideoTSFiles
    MessageModal>VideoTSFiles
    Separate>VideoTSFiles,;,VideoTSFile_names
    MessageModal>Num Files: %VideoTSFile_names_count%
        If>file_names_count>0
            MessageModal>Has files
        Else
            MessageModal>Movie Files do not exist-Process Cancelled
        GoSub>Exit_Script
        Endif
END>VerifyFilesPresent2
Once I got it to run, I took the subroutine VerifyFilesPresent2 and put it verbatim into my actual script. Now, VerifyFilesPresent2 doesn't show that any files exist, and it shows a file count of 0.

It seems that the subroutine calling VerifyFilesPresent2 is affecting its output. Below is the version where I'm having problems:

Code: Select all

SRT>Find_Movie_Directory
Let>GFL_TYPE=1
GetFileList>D:\BlackCats_Documents\My_Videos\DVD\*,files
MessageModal>files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
    If>file_names_count=0,end
    Let>k=0
    Repeat>k
    Let>k=k+1
    ChangeDirectory>file_names_%k%
    MessageModal>file_names_%k%
    IfDirExists>MovieFolder2
        ChangeDirectory>MovieFolder2
        Let>varMoviePathToGenre=file_names_%k%
        Let>varMoviePathToMovie=%varMoviePathToGenre%\%varMovieName%
        //MessageModal>varMoviePathToGenre
        //GoSub>CheckExistenceMobileMovieFile_mp4_Extension
        //GoSub>CheckExistenceVIDEO_TSDirectory
        GoSub>VerifyFilesPresent2
        GoTo>end
    Else
    Endif

    Until>k,file_names_count
Label>end
END>Find_Movie_Directory

SRT>VerifyFilesPresent2
    GetFileList>D:\BlackCats_Documents\My_Videos\DVD\Test\MovieFolder2\VIDEO_TS\*,VideoTSFiles
    MessageModal>VideoTSFiles
    Separate>VideoTSFiles,;,VideoTSFile_names
    MessageModal>Num Files: %VideoTSFile_names_count%
        If>file_names_count>0
            MessageModal>Has files
        Else
            MessageModal>Movie Files do not exist-Process Cancelled
        GoSub>Exit_Script
        Endif
END>VerifyFilesPresent2

The Find_Movie_Directory subroutine along with one of the other disabled GoSub commands defines the directory to look at in VerifyFilesPresent2. I see this path is reporting correct.y via MessageModal. However, defining the path this way reports the same wrong results as typing the path directly into VerifyFilesPresent2 as I have above.

I'm not sure what I am doing wrong. Does it have to do with the fact that I changed the directory in the first subroutine?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jan 22, 2011 7:42 am

In your first subroutine you have:

Let>GFL_TYPE=1

This has global effect. I suspect in your second subroutine you want to do:

Let>GFL_TYPE=0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BlackCat
Newbie
Posts: 13
Joined: Mon Dec 20, 2010 12:32 am

Post by BlackCat » Sat Jan 22, 2011 7:42 pm

mtettmar wrote:In your first subroutine you have:

Let>GFL_TYPE=1

This has global effect. I suspect in your second subroutine you want to do:

Let>GFL_TYPE=0
Thanks, that was it. I didn't even think about that command globally affecting things after I executed it. I was thinking it would reset at the end of the subroutine. I should probably go back and look at a few other suspect areas as well. Thanks again.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jan 22, 2011 8:14 pm

Scope is global by default. This can be changed by setting LOCALVARS to 1:

Code: Select all

Let>LOCALVARS=1
GoSub>A
GoSub>B

SRT>A
  Let>GFL_TYPE=1
  GetFileList>%USERDOCUMENTS_DIR%,res
END>A

SRT>B
  GetFileList>%USERDOCUMENTS_DIR%\*.*,res1
END>B
In this example the second GetFileList reverts to files because GFL_TYPE set in subroutine A only has scope within subroutine A because LOCALVARS has been set to 1.

See the section on scope in the help file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BlackCat
Newbie
Posts: 13
Joined: Mon Dec 20, 2010 12:32 am

Post by BlackCat » Sat Jan 22, 2011 8:17 pm

mtettmar wrote:Scope is global by default. This can be changed by setting LOCALVARS to 1:

Code: Select all

Let>LOCALVARS=1
GoSub>A
GoSub>B

SRT>A
  Let>GFL_TYPE=1
  GetFileList>%USERDOCUMENTS_DIR%,res
END>A

SRT>B
  GetFileList>%USERDOCUMENTS_DIR%\*.*,res1
END>B
In this example the second GetFileList reverts to files because GFL_TYPE set in subroutine A only has scope within subroutine A because LOCALVARS has been set to 1.

See the section on scope in the help file.
Thanks, I'll read up on that.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts