Sign in to follow this  
Followers 0
Ashalshaikh

_FileOpenDialogToArray.

5 posts in this topic

#1 ·  Posted (edited)

Hi .

First :: My English Is Very Bad <<<< So I'm Sorry. >_<

It's Sample Function

Thank You

;~ #Example--------------------------------
;~ $DDD = _FileOpenDialogToArray("Select Files", @DesktopDir, "All (*.*)")
;~ _ArrayDisplay($DDD)
;~ #Example -------------- End-------------



; #FUNCTION# ====================================================================================================================
; Name...........: _FileOpenDialogToArray
; Description ...: Show FileOpenDialog & Return Files In Array By Full Path.
; Syntax.........: _FileOpenDialogToArray($title, $initdir, $filter, [$options = 4, [$defaultname = "", [$hwnd = ""]]])
; Parameters ....: Look At FileOpenDialog In HelpFile.
; Return values .: Success    - Full Paths In Array
;                  Failure    - 0
;                      @Error - Look At FileOpenDialog In HelpFile.
; Author ........: Ashalshaikh : Ahmad ALshaikh
; Remarks .......: Return (Full Path) In Array
; ===============================================================================================================================
#include <Array.au3>
Func _FileOpenDialogToArray($title, $initdir, $filter, $options = 4, $defaultname = "", $hwnd = "")
    Local $ERR[1] = [0]
    Local $Files = FileOpenDialog($title, $initdir, $filter, $options, $defaultname, $hwnd)
    If @error Then SetError(@error, "", $ERR)
    If StringInStr($Files, "|") Then
        Local $SS = StringSplit($Files, "|")
        $Folder = $SS[1]
        For $x = 2 To $SS[0]
            $SS[$x] = $Folder & "\" & $SS[$x]
        Next
        _ArrayDelete($SS, 1)
        $SS[0] -= 1
        Return $SS
    Else
        Local $Arr[2] = [1, $Files]
        Return $Arr
    EndIf
EndFunc   ;==>_FileOpenDialogToArray

Thank You !!

Edited by Ashalshaikh

Share this post


Link to post
Share on other sites



Hi.

Here is my version i had to make when i needed to list all the files i wanted to unpack with winrar.

#include <UnRAR.au3>
#include <File.au3>
#include <Array.au3>

Local $ArchiveFile[1]
Global $Cancel = False

HotKeySet("{Esc}", "_CancelUnpack")

$copy1 = FileInstall("C:\Users\Public\Backup\Batch files\Install Files\unrar.dll", "unrar.dll", 1)

$oFolder = "H:\To Burn\To Laptop\"
If Not FileExists($oFolder) Then $oFolder = "D:\Laptop\Unpacked\" ; set for testing purposes
$iFolder = "H:\To Burn\"
If Not FileExists($iFolder) Then $iFolder = "D:\Laptop\Unpacked\" ; set for testing purposes

$OutputFolder = FileSelectFolder("Browse for output path", $oFolder, 1)
If $OutputFolder = "" Then Exit                                   ; if its cancelled then exit script
$InputFolder = FileSelectFolder("Browse for output path", $iFolder, 1)
If $InputFolder = "" Then Exit                                    ; if its cancelled then exit script
$ArchiveFile[0] = FileOpenDialog("Select the archive file", $InputFolder, "Archive files (*.rar)")
Do
$ask = FileOpenDialog("Select the archive file", $InputFolder, "Archive files (*.rar)")
if $ask = "" Then ExitLoop                                      ; if its cancelled then no more files to add
_ArrayAdd($ArchiveFile, $ask)
Until False
...more code...

Your code seems much cleaner. Thanks >_<

Share this post


Link to post
Share on other sites

Hi.

Here is my version i had to make when i needed to list all the files i wanted to unpack with winrar.

#include <UnRAR.au3>
#include <File.au3>
#include <Array.au3>

Local $ArchiveFile[1]
Global $Cancel = False

HotKeySet("{Esc}", "_CancelUnpack")

$copy1 = FileInstall("C:\Users\Public\Backup\Batch files\Install Files\unrar.dll", "unrar.dll", 1)

$oFolder = "H:\To Burn\To Laptop\"
If Not FileExists($oFolder) Then $oFolder = "D:\Laptop\Unpacked\" ; set for testing purposes
$iFolder = "H:\To Burn\"
If Not FileExists($iFolder) Then $iFolder = "D:\Laptop\Unpacked\" ; set for testing purposes

$OutputFolder = FileSelectFolder("Browse for output path", $oFolder, 1)
If $OutputFolder = "" Then Exit                                   ; if its cancelled then exit script
$InputFolder = FileSelectFolder("Browse for output path", $iFolder, 1)
If $InputFolder = "" Then Exit                                    ; if its cancelled then exit script
$ArchiveFile[0] = FileOpenDialog("Select the archive file", $InputFolder, "Archive files (*.rar)")
Do
$ask = FileOpenDialog("Select the archive file", $InputFolder, "Archive files (*.rar)")
if $ask = "" Then ExitLoop                                      ; if its cancelled then no more files to add
_ArrayAdd($ArchiveFile, $ask)
Until False
...more code...

Your code seems much cleaner. Thanks >_<

Great idea

But the problem is that the function out more than once

Thank You !!

:(

Share this post


Link to post
Share on other sites

Very nice. Will come in handy.

Thanks for sharing...

Share this post


Link to post
Share on other sites

Thanks !! >_

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