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 

fileselectfile and multiple files

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
3tones



Joined: 14 Dec 2004
Posts: 45
Location: Minneapolis, MN

PostPosted: Sat Jan 15, 2005 2:55 am    Post subject: fileselectfile and multiple files Reply with quote

I don't know if this has been changed in recent versions or if there already is an option for this...

If fileselect file is set to accept multiple files, the return is as follows (at least in 1.0.24)
single file:
Code:
c:\myfolder\file1.txt`n

multiple files:
Code:
c:\myfolder\`nfile1.txt`nfile2.txt`n


If the parse loop is used as given in the help file:
Code:
; MULTI-SELECT EXAMPLE:
FileSelectFile, files, 7  ; 7 = Multiselect existing files.
if files =
{
   MsgBox, The user pressed cancel.
   return
}
Loop, parse, files, `n
{
   if A_LoopField =  ; A blank field marks the end of the list.
      break
   if a_index = 1
      MsgBox, The selected files are all contained in %A_LoopField%.
   else
   {
      MsgBox, 4, , The next file is %A_LoopField%.  Continue?
      IfMsgBox, No, break
   }
}
return

it will not work properly when selecting one file. I propose that whenever the multiselect option is used, it will always return as shown here:
Code:
 c:\myfolder\`nfile1.txt`n
rather then as shown above. I have also written a little code to do this when needed:
Code:

  ;make 2 lines if one file
  ;look for more than one `n
  stringgetpos, newline, filelist, `n, R2
  ;if only one
  if ErrorLevel <> 0
    {
    ;look for last slash
    stringgetpos, lastslash, filelist, \, R
    lastslash += 1
    stringleft, leftside, filelist, %lastslash%
    lastslash += 1
    stringmid, rightside, filelist, %lastslash%, 100
   ;add `n between last slash and filename
    filelist = %leftside%`n%rightside%
    }
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Jan 15, 2005 10:16 pm    Post subject: Re: fileselectfile and multiple files Reply with quote

You're right, this was really bad; thanks for spotting it. I've updated the installer with the following change:

Improved FileSelectFile with a easier multi-select option. Although the old multi-select option will continue to function as before, it has been marked obsolete in the help file due to the difficulty of parsing its results.
Back to top
View user's profile Send private message Send e-mail
3tones



Joined: 14 Dec 2004
Posts: 45
Location: Minneapolis, MN

PostPosted: Sat Jan 15, 2005 11:47 pm    Post subject: Reply with quote

Smooth... thanks for fixing that so promptly. Works great!

Tom
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List 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