AutoHotkey Community

It is currently May 27th, 2012, 5:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: November 16th, 2005, 11:59 pm 
Offline

Joined: October 1st, 2005, 9:55 pm
Posts: 775
Location: Texas, USA
AHK v1.0.40.05

I noticed this when I was coding a simple file search routine... Here's some code to explain:

Code:
$SeachFolder:="C:\"
$SearchPattern:="*.exe"
loop %$SeachFolder%\%$SearchPattern%,,1  ;-- Intentional double back slashes
    {
    m=
    m=%m%A_LoopFileAttrib=%A_LoopFileAttrib%`n
    m=%m%A_LoopFileDir=%A_LoopFileDir%`n
    m=%m%A_LoopFileExt=%A_LoopFileExt%`n
    m=%m%A_LoopFileFullPath=%A_LoopFileFullPath%`n
    m=%m%A_LoopFileLongPath=%A_LoopFileLongPath%`n
    m=%m%A_LoopFileName=%A_LoopFileName%`n
    m=%m%A_LoopFileShortName=%A_LoopFileShortName%`n
    m=%m%A_LoopFileShortPath=%A_LoopFileShortPath%`n
    m=%m%A_LoopFileSize=%A_LoopFileSize%`n
    m=%m%A_LoopFileSizeKB=%A_LoopFileSizeKB%`n
    m=%m%A_LoopFileSizeMB=%A_LoopFileSizeMB%`n
    m=%m%A_LoopFileTimeAccessed=%A_LoopFileTimeAccessed%`n
    m=%m%A_LoopFileTimeCreated=%A_LoopFileTimeCreated%`n
    m=%m%A_LoopFileTimeModified=%A_LoopFileTimeModified%
    msgbox %m%
    break
    }
return


In this example, A_LoopFileLongPath returns an expected value:

C:\WINDOWS\Ralph.exe

However, A_LoopFileDir, A_LoopFileFullPath, and A_LoopFileShortPath return values in the following format:

C:\\WINDOWS\Ralph.exe

Of course, the workaround is to fix the variables before the search loop is executed. I just wondering if these system variables are returning the correct (or expected value) and if so, why isn't A_LoopFileLongPath in the same format?

Thank you for your assistance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2005, 6:16 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
This is by design because for performance reasons, the built-in variables A_LoopFileFullPath, ShortPath, and Dir use the same path that was specified at the top of the loop.

Since the loop successfully retrieves files even with double backslash, some or all OSes tolerate them. I think you already mentioned the work-around, which is to omit the trailing backslash from a root folder when it is used as a path prefix.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group