AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems using FileExist(FilePattern)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Murp|e



Joined: 12 Jan 2007
Posts: 261
Location: Norway

PostPosted: Sun Feb 03, 2008 10:51 pm    Post subject: Problems using FileExist(FilePattern) Reply with quote

I am trying to set the variable sfilename to blank if sfullpath is a folder. It's really simple, but for some reason I haven't been able to get it to work at all.

This is my code:
Code:
if InStr(FileExist(sfullpath), "D")
{
  msgbox, "%sfullpath%" is a folder!`nSet "%sfilename%" to blank!
  sfilename =
}


While debugging I tried this code:
Code:
AttributeString := FileExist(sfullpath)
msgbox, File or folder: "%sfullpath%"`nAttributes: "%AttributeString%"


AttributeString is almost always blank, it returned "A" a couple of times, but it never returned a string containing "D" even though I hard coded the variable sfullpath to be the path of a folder. I've sucessfully used the FileExist function to test for folders before, any ideas as to what I could be doing wrong?
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Feb 04, 2008 8:10 am    Post subject: Reply with quote

Check the variable sfullpath before calling InStr()

The following works for me:

Code:
sfullpath := A_WinDir

if InStr(FileExist(sfullpath), "D")
{
  msgbox, "%sfullpath%" is a folder!`nSet "%sfilename%" to blank!
  sfilename =
}


Smile
Back to top
View user's profile Send private message
Murp|e



Joined: 12 Jan 2007
Posts: 261
Location: Norway

PostPosted: Mon Feb 04, 2008 8:29 am    Post subject: Reply with quote

SKAN,

Thanks for your reply. Unfortunately it works for me too(!). I've been checking sfullpath over and over again and checking that the paths actually exist by copying them, pasting them into the run box and seeing that the folders open.

Stupid bugz....
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Feb 04, 2008 8:54 am    Post subject: Reply with quote

Murp|e wrote:
I've been checking sfullpath over and over again and checking that the paths actually exist by copying them, pasting them into the run box and seeing that the folders open.


er.. Maybe you are using := and not wrapping the path with double quotes ?

Code:
EnvGet, SD, SystemDrive
sfullpath=%SD%\Documents and Settings\%A_UserName%\Local Settings\Temp
MsgBox, % sFullPath

if InStr(FileExist(sfullpath), "D")
{
  msgbox, "%sfullpath%" is a folder!`nSet "%sfilename%" to blank!
  sfilename =
}


Rolling Eyes
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group