Sign in to follow this  
Followers 0
wimhek

Fileopendialog open songle or mltiple files

4 posts in this topic

Has anybody coded the ultimate commands after the fileopendialog (option 1+4). The logic after selecting 1 file or multiple files is different.

Thanx.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

A few ways you could tackle this...here's one:

$var = _MyFileOpenDialog()

#region - Just for displaying results
If IsArray($var) Then
    Local $tmp
    For $i = 2 To UBound($var) - 1
        $tmp &= $var[$i] & @LF
    Next
    MsgBox(0, '', $tmp)
Else
    MsgBox(0, '', $var)
EndIf
#endregion

Func _MyFileOpenDialog()
    Local $file, $array
    $file = FileOpenDialog('Select File(s)', @HomeDrive, 'All Files (*.*)', 7)
    If @error Then Return 'No files selected'
    If Not StringInStr($file, '|') Then Return $file
    $array = StringSplit($file, '|')
    If StringRight($array[1], 1) <> '\' Then $array[1] = $array[1] & '\'
    For $i = 2 To $array[0]
        $array[$i] = $array[1] & $array[$i]
    Next
    Return $array
EndFunc
Edited by xcal

Share this post


Link to post
Share on other sites

Has anybody coded the ultimate commands after the fileopendialog (option 1+4). The logic after selecting 1 file or multiple files is different.

Thanx.

Thank You, I codes something similair, but your code looks more compact.

At the end I have still a problem. When selected one file i must proces $files, and when selected more files I must process $tmp.

So there is stiil needed some coding like array delete or arrayinsert.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I made a slight mistake. See my edit, incase that helps.

edit - You just need to check if it's returning an array (IsArray(), or change the function to always return an array.)

Edited by xcal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0