Multiple File selection with listbox Add Remove Up and Down

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Multiple File selection with listbox Add Remove Up and Down

Post by stitch22 » Sun Dec 30, 2012 4:01 pm

As I was getting ready to post this I solved my own problem. Which was setting the SelectedIndex when MultiSelect is True. I need this for the UP DOWN buttons to function. The work around was to toggle MultiSelect settings in the updown subroutines. That did the trick, so obviuos I just couldn't see it. Ive got the functionality I want but I don't like the display of Full paths.

Does anybody know If its possible to display the file name but pass the paths as the value to the final output?

I was thinking of maybe doing a multi-column list with both Filepath and File name and hidding the paths from view. Don't know if that is even possible.

Also in windows7 I get permission denied runtime error:70 when selecting some folders?


Code: Select all

vbstart
dim recursion
Set FSO = CreateObject("Scripting.FileSystemObject")
Sub ShowSubFolders(path)
set Folder = FSO.GetFolder(path)
For Each Subfolder in Folder.SubFolders
 recursion = recursion&Subfolder.Path&vbcrlf
 ShowSubFolders Subfolder
Next
End Sub
VBEND
let>Selected_files=
Let>ext=*

Dialog>MultiSelect
object MultiSelect: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 420
  ClientWidth = 848
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 25
    Width = 521
    Height = 395
    Align = alLeft
    Caption = 'Panel1'
    TabOrder = 0
    ExplicitHeight = 497
    object Splitter1: TSplitter
      Left = 226
      Top = 1
      Width = 7
      Height = 393
      MinSize = 100
      ResizeStyle = rsUpdate
      ExplicitHeight = 495
    end
    object MSListBox1: tMSListBox
      Left = 1
      Top = 1
      Width = 225
      Height = 393
      Align = alLeft
      BevelKind = bkFlat
      ItemHeight = 13
      Sorted = True
      TabOrder = 0
      SelectedIndex = -1
      ExplicitHeight = 554
    end
    object MSListBox2: tMSListBox
      Left = 233
      Top = 1
      Width = 287
      Height = 393
      Align = alClient
      ItemHeight = 13
      MultiSelect = True
      TabOrder = 1
      SelectedIndex = -1
    end
  end
  object Panel3: TPanel
    Left = 577
    Top = 25
    Width = 271
    Height = 395
    Align = alClient
    AutoSize = True
    Caption = 'Panel3'
    TabOrder = 1
    ExplicitLeft = 576
    ExplicitWidth = 288
    ExplicitHeight = 556
    object MSListBox3: tMSListBox
      Left = 1
      Top = 1
      Width = 269
      Height = 393
      Align = alClient
      BevelKind = bkFlat
      ItemHeight = 13
      MultiSelect = True
      TabOrder = 0
      SelectedIndex = -1
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 0
    Width = 848
    Height = 25
    Align = alTop
    TabOrder = 2
    object Label1: TLabel
      Left = 48
      Top = 8
      Width = 68
      Height = 13
      Caption = 'Select a folder'
    end
    object Label2: TLabel
      Left = 288
      Top = 8
      Width = 63
      Height = 13
      Caption = 'File Selection'
    end
    object Label3: TLabel
      Left = 664
      Top = 8
      Width = 29
      Height = 13
      Caption = 'myList'
    end
    object MSButton7: tMSButton
      Left = 147
      Top = 3
      Width = 54
      Height = 20
      Caption = 'Browse'
      TabOrder = 0
      DoBrowse = False
      InitialDir = '"c:\"'
      BrowseStyle = fbFolder
    end
  end
  object Panel4: TPanel
    Left = 521
    Top = 25
    Width = 56
    Height = 395
    Align = alLeft
    TabOrder = 3
    object MSButton1: tMSButton
      Left = 12
      Top = 95
      Width = 29
      Height = 25
      Caption = '->'
      TabOrder = 0
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton2: tMSButton
      Left = 12
      Top = 137
      Width = 29
      Height = 25
      Caption = '<-'
      TabOrder = 3
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton3: tMSButton
      Left = 12
      Top = 221
      Width = 27
      Height = 25
      Caption = 'CLR'
      TabOrder = 1
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton4: tMSButton
      Left = 12
      Top = 179
      Width = 27
      Height = 25
      Caption = 'CLN'
      TabOrder = 2
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton5: tMSButton
      Left = 12
      Top = 263
      Width = 33
      Height = 25
      Caption = 'UP'
      TabOrder = 4
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton6: tMSButton
      Left = 12
      Top = 305
      Width = 37
      Height = 25
      Caption = 'DWN'
      TabOrder = 5
      DoBrowse = False
      BrowseStyle = fbOpen
    end
  end
end
EndDialog>MultiSelect

SRT>DoBrowse
SetDialogProperty>MultiSelect,MSButton7,DoBrowse,True
GetDialogProperty>MultiSelect,MSButton7,Filename,path
 vbrun>ShowSubFolders,%path%
 vbeval>recursion,hFList
SetDialogProperty>MultiSelect,MSListBox1,Text,%hFList%
END>DoBrowse

AddDialogHandler>MultiSelect,MSListBox1,OnClick,FolderSelect
AddDialogHandler>MultiSelect,MSButton1,OnClick,FileAdd
AddDialogHandler>MultiSelect,MSButton2,OnClick,FileRem
AddDialogHandler>MultiSelect,MSButton3,OnClick,ClearList
AddDialogHandler>MultiSelect,MSButton4,OnClick,CleanList
AddDialogHandler>MultiSelect,MSButton5,OnClick,Move_Up
AddDialogHandler>MultiSelect,MSButton6,OnClick,Move_Down
AddDialogHandler>MultiSelect,MSButton7,OnClick,DoBrowse

Show>MultiSelect,r

// Do Somethin with the list
Messagemodal>Do Somethin with myList%CRLF%%CRLF%%Selected_files% 
Exit

SRT>CleanList
  StringReplace>%Selected_files%,--removed--%CRLF%,,Selected_files
  SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>CleanList

SRT>ClearList
  let>Selected_files=
  SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>ClearList

SRT>FileRem
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,remfile_list
Separate>Selected_files,CRLF,selected_items
GetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,rn
Separate>remfile_list,CRLF,rem_items
let>re=0
Repeat>re
  let>re=re+1
  StringReplace>%Selected_files%,rem_items_%re%,--removed--,Selected_files
Until>re,rem_items_count
SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>FileRem

SRT>FileAdd
GetDialogProperty>MultiSelect,MSListBox2,SelectedItems,file_list
let>Selected_files=%file_list%%CRLF%%Selected_files%
SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>FileAdd

SRT>FolderSelect
GetDialogProperty>MultiSelect,MSListBox1,SelectedItems,Selected_list
Separate>Selected_List,CRLF,selected_items
Let>GFL_TYPE=0
GetFileList>%selected_items_1%\*.%ext%,theList,CRLF
SetDialogProperty>MultiSelect,MSListBox2,Text,theList
END>FolderSelect

SRT>Move_Up
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,False
GetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,rn
If>%rn%=0
Goto>end_of_up_sub
Else
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,rvo
Let>rn=%rn%-1
GoSub>swapItem
Endif
Label>end_of_up_sub
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,True
END>Move_Up

SRT>Move_Down
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,False
GetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,rn
If>%rn%=-1
Goto>end_of_down_sub
else
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,rvo
Let>rn=%rn%+1
GoSub>swapItem
Endif
Label>end_of_down_sub
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,True
END>Move_Down

SRT>swapItem
SetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,%rn%
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,rvn
StringReplace>%Selected_files%,%rvo%,Rp1,Selected_files
StringReplace>%Selected_files%,%rvn%,%rvo%,Selected_files
StringReplace>%Selected_files%,Rp1,%rvn%,Selected_files
SetDialogProperty>MultiSelect,MSListBox3,Text,%Selected_files%
SetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,%rn%
END>swapItem
Thanks in advance for any thoughts and comments.

User avatar
Meryl
Staff
Posts: 124
Joined: Wed Sep 19, 2012 1:53 pm
Location: Texas
Contact:

Post by Meryl » Wed Jan 02, 2013 4:32 pm

On the permissions error, did you grant the proper permissions? Those folders may not have the right permissions setting.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jan 02, 2013 4:51 pm

If you're on Windows 7 using the default setup then you are running Macro Scheduler with ordinary privileges and not as Admin and some folders, e.g. System32 require Administrator privileges for you to read from them. That's probably the cause of the errors. If you need access to such folders then run Macro Scheduler as admin (right click, run as Admin).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Fri Jan 04, 2013 9:54 pm

OK i see, the security is on those folders most users should not be in anyway.
The ones I realy want are fine.
Thanks.

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Fri Jan 04, 2013 9:57 pm

Any Idea on on a better way to display the list?
I have been busy on other projects and have not tried the mutilple columns yet.

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: Multiple File selection with listbox Add Remove Up and D

Post by CyberCitizen » Sun Jan 06, 2013 10:55 pm

stitch22 wrote:Does anybody know If its possible to display the file name but pass the paths as the value to the final output?
Do you mean something like this?

Code: Select all

Let>INPUT_BROWSE=1
Input>ExecutableName,Please Select The Executable / Icon File In The Folder%CRLF%You Would Like To Change The Folder Icon For...,

IF>ExecutableName=
   MDL>Please select a exe or ico file...
   Goto>Start
ELSE
   Separate>ExecutableName,\,ExecutableName
   let>MyCount=%ExecutableName_count%
   let>FileName=ExecutableName_%MyCount%
   let>MyCount=%MyCount%-1
   let>FolderName=ExecutableName_%MyCount%
   let>exclude=%FolderName%\%FileName%
   StringReplace>ExecutableName,%exclude%,,FolderPath
   Goto>CreateDesktopINI
ENDIF
FIREFIGHTER

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Tue Jan 08, 2013 7:11 am

Yes, and thanks.
I took your idea and put this together.

Code: Select all

// allows end user to select files from multiple directories
// and also multiple file selection with in a directory
// and re-order the list to suit their process

VBSTART
dim recursion
Set FSO = CreateObject("Scripting.FileSystemObject")
Sub ShowSubFolders(path)
set Folder = FSO.GetFolder(path)
For Each Subfolder in Folder.SubFolders
 recursion = recursion&Subfolder.Path&vbcrlf
 ShowSubFolders Subfolder
Next
End Sub
VBEND
// change to folder Browse. the user would normally not be allowed
// to Browse. the initial directory would be set to their root folder
Let>INPUT_BROWSE=2
Input>ExecutableName,Please Select The Executable / Icon File In The Folder%CRLF%You Would Like To Change The Folder Icon For...,

IF>ExecutableName=
   MDL>Please select a exe or ico file...
   Goto>Start
ELSE
// Pass the return variable to to vb for recursion
// to obtain a list of folder and sub folders
// to present the user with something similar to a tree
VBRun>ShowSubFolders,%ExecutableName%

// Retrieve the new list of folders and subfolders as
// CRLF delimited list
VBEval>recursion,FolderList

// Create an array of folders and Loop thru 
// to display a list of folder names for user selection.
// When the folder is selected Present the user with a lsit of files
// they can mult-select from  and re-organize
Separate>FolderList,CRLF,FolderArray
Let>Output=
Let>FList=
Let>i=1
Repeat>i
Let>i=i+1
   Separate>FolderArray_%i%,\,ExecutableName
   let>FolderPath=FolderArray_%i%
   let>MyCount=%ExecutableName_count%
   // pad with spaces for display
   VBeval>Space(3*%MyCount%),Folderpad
   let>FileName=ExecutableName_%MyCount%
   let>MyCount=%MyCount%-1
   let>FolderName=ExecutableName_%MyCount%
   let>exclude=%FolderName%\%FileName%
   //StringReplace>ExecutableName,%exclude%,,FolderPath
   // add enough "300" padding to move path out of view in listbox
   VBeval>Space(300),pad
   // add a delimiter for separating path from name
   Let>Delim=|
   Let>Output=%Output%%Folderpad%%exclude%%pad%%Delim%%FolderPath%%CRLF%
Until>i,FolderArray_Count
ENDIF

Dialog>Dialog1
object Dialog1: TForm
  Left = 509
  Top = 138
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 282
  ClientWidth = 431
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesktopCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSListBox1: tMSListBox
    Left = 0
    Top = 0
    Width = 249
    Height = 281
    ItemHeight = 13
    TabOrder = 0
    SelectedIndex = -1
  end
  object MSListBox2: tMSListBox
    Left = 264
    Top = 0
    Width = 171
    Height = 281
    ItemHeight = 13
    MultiSelect = True
    TabOrder = 1
    SelectedIndex = -1
  end
  object MSButton1: tMSButton
    Left = 368
    Top = 253
    Width = 56
    Height = 25
    Caption = 'ADD'
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,MSListBox1,OnClick,FolderSelect
AddDialogHandler>Dialog1,MSButton1,OnClick,FileAdd

// place Ouput into Listbox of appropriate width
SDP>Dialog1,MSListBox1,Text,%Output%
show>Dialog1,r

// use same technique for files and Viola!
// nice!
SRT>FolderSelect
GetDialogProperty>Dialog1,MSListBox1,SelectedItems,Selected_list
Separate>Selected_List,|,selected_items
Let>GFL_TYPE=0
// show all files for testing. Users only allowed specific file type
GetFileList>%selected_items_2%\*.*,FileList,CRLF
Separate>%FileList%,%crlf%,FileArray
Let>i=0
repeat>i
let>i=i+1
Separate>FileArray_%i%,\,nameList
let>name=nameList_%nameList_count%
VBEVal>Space(100),pad
Let>fPath=FileArray_%i%
Let>FList=%FList%%name%%pad%|%fPath%%CRLF%
Until>i,FileArray_Count
// place file list in multiSelect listbox
SetDialogProperty>Dialog1,MSListBox2,Text,FList
END>FolderSelect

// wash, rinse, repeat, and :)

// the selected file list from this goes into the re-order list box 
// the user can now add remove and re-order the list
// to suit their process

SRT>FileAdd
GetDialogProperty>Dialog1,MSListBox2,SelectedItems,file_list
Separate>file_list,CRLF,PathList
Let>i=0
let>DisplayPaths=
repeat>i
let>i=i+1
Separate>PathList_%i%,|,MultiplFilePaths
let>DisplayPaths=%DisplayPaths%%MultiplFilePaths_2%%CRLF%
Until>i,PathList_Count
let>MSG_WIDTH=600
Messagemodal>Go back and add more or less then %CRLF%Go Process this List%CRLF%%DisplayPaths%
END>FileAdd
With A little more clean up I think it may be workable.
The users directories do not conatin a lot of files, on average about 5.
but the directory structure can be crazy.

Thanks Again.

User avatar
stitch22
Junior Coder
Posts: 31
Joined: Mon Oct 20, 2008 3:18 pm
Location: California
Contact:

Post by stitch22 » Tue Jan 08, 2013 5:56 pm

Here is cleaned up version using a similar technique of Parsing the path. Except the VBscript is using a more versitile Disconnected Recordset. Which I found and built based on this article.

http://technet.microsoft.com/en-us/maga ... zzleAnswer

Warning! Xp can be very slow using this technique when "recalling" the list. Windows 7 does not have this issue. More resources faster pc?

With this one the path is parsed and place into a recordset. given that the recordset can be anything we want we could glean more information from the file system if desired and use it for sorting and searching. Probably pretty fast to. Although the first time loading the list might be slow. I have not explored those options yet.

It seems to work pretty well. I would rather have a Mutiple file select Explorer Window. But I can't find that option?

Code: Select all

vbstart
dim path
dim recursion
Set FSO = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Const adVarChar = 200
Const MaxCharacters = 255
Const adDouble = 5
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "Name",  adVarChar, MaxCharacters
DataList.Fields.Append "Path",  adVarChar, MaxCharacters
DataList.Fields.Append "ParentPath",  adVarChar, MaxCharacters
DataList.Fields.Append "ParentFolder",  adVarChar, MaxCharacters
DataList.Fields.Append "Padding", adDouble
sub CreateRecordSet
DataList.Open
recursion=path&vbcrlf
end sub
Sub ShowSubFolders(path)
set Folder = FSO.GetFolder(path)
For Each Subfolder in Folder.SubFolders
subcount=Split(Subfolder.Path,"\",-1,1)
padding=UBound(subcount)
DataList.AddNew
DataList("Name")= Subfolder.Name
DataList("Path")= Subfolder.Path
DataList("ParentPath")= Subfolder.ParentFolder
DataList("ParentFolder")= subcount(padding-1)
DataList("Padding")= padding
DataList.Update
ShowSubFolders Subfolder
Next
End Sub
Sub GetList
DataList.MoveFirst
Do Until DataList.EOF
recursion=recursion&Space(3*DataList.Fields.Item("Padding"))&DataList.Fields.Item("ParentFolder")&"\"&DataList.Fields.Item("Name")&space(150)&";"&DataList.AbsolutePosition&vbcrlf
DataList.MoveNext
Loop
End Sub
Function GetRecord(num)
DataList.MoveFirst
myRecord =num
DataList.Move myRecord
GetRecord=DataList.Fields.Item("Path")
end function
Function checkState
checkState=Datalist.State
End Function
Sub  Close
DataList.Close
End Sub
VBEND

// added semi colon to tag blank file in list
// is removed in FileAdd subroutine
let>Selected_files=;

// set file type ext here
Let>ext=*

Dialog>MultiSelect
object MultiSelect: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 420
  ClientWidth = 848
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 25
    Width = 521
    Height = 395
    Align = alLeft
    Caption = 'Panel1'
    TabOrder = 0
    ExplicitHeight = 497
    object Splitter1: TSplitter
      Left = 226
      Top = 1
      Width = 7
      Height = 393
      MinSize = 100
      ResizeStyle = rsUpdate
      ExplicitHeight = 495
    end
    object MSListBox1: tMSListBox
      Left = 1
      Top = 1
      Width = 225
      Height = 393
      Align = alLeft
      BevelKind = bkFlat
      ItemHeight = 13
      TabOrder = 0
      SelectedIndex = -1
    end
    object MSListBox2: tMSListBox
      Left = 233
      Top = 1
      Width = 287
      Height = 393
      Align = alClient
      ItemHeight = 13
      MultiSelect = True
      TabOrder = 1
      SelectedIndex = -1
    end
  end
  object Panel3: TPanel
    Left = 577
    Top = 25
    Width = 271
    Height = 395
    Align = alClient
    AutoSize = True
    Caption = 'Panel3'
    TabOrder = 1
    ExplicitLeft = 576
    ExplicitWidth = 288
    ExplicitHeight = 556
    object MSListBox3: tMSListBox
      Left = 1
      Top = 1
      Width = 269
      Height = 393
      Align = alClient
      BevelKind = bkFlat
      ItemHeight = 13
      MultiSelect = True
      TabOrder = 0
      SelectedIndex = -1
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 0
    Width = 848
    Height = 25
    Align = alTop
    TabOrder = 2
    object Label1: TLabel
      Left = 48
      Top = 8
      Width = 68
      Height = 13
      Caption = 'Select a folder'
    end
    object Label2: TLabel
      Left = 288
      Top = 8
      Width = 102
      Height = 13
      Caption = 'Multiple File Selection'
    end
    object Label3: TLabel
      Left = 664
      Top = 8
      Width = 29
      Height = 13
      Caption = 'myList'
    end
    object MSButton7: tMSButton
      Left = 147
      Top = 3
      Width = 54
      Height = 20
      Caption = 'Browse'
      TabOrder = 0
      DoBrowse = False
      InitialDir = '"c:\"'
      BrowseStyle = fbFolder
    end
  end
  object Panel4: TPanel
    Left = 521
    Top = 25
    Width = 56
    Height = 395
    Align = alLeft
    TabOrder = 3
    object MSButton1: tMSButton
      Left = 12
      Top = 95
      Width = 29
      Height = 25
      Caption = '->'
      TabOrder = 0
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton2: tMSButton
      Left = 12
      Top = 137
      Width = 29
      Height = 25
      Caption = '<-'
      TabOrder = 3
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton3: tMSButton
      Left = 12
      Top = 221
      Width = 27
      Height = 25
      Caption = 'CLR'
      TabOrder = 1
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton4: tMSButton
      Left = 12
      Top = 179
      Width = 27
      Height = 25
      Caption = 'CLN'
      TabOrder = 2
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton5: tMSButton
      Left = 12
      Top = 263
      Width = 33
      Height = 25
      Caption = 'UP'
      TabOrder = 4
      DoBrowse = False
      BrowseStyle = fbOpen
    end
    object MSButton6: tMSButton
      Left = 12
      Top = 305
      Width = 37
      Height = 25
      Caption = 'DWN'
      TabOrder = 5
      DoBrowse = False
      BrowseStyle = fbOpen
    end
  end
end
EndDialog>MultiSelect

AddDialogHandler>MultiSelect,MSListBox1,OnClick,FolderSelect
AddDialogHandler>MultiSelect,MSListBox2,OnClick,FileSelect
AddDialogHandler>MultiSelect,MSButton1,OnClick,FileAdd
AddDialogHandler>MultiSelect,MSButton2,OnClick,FileRem
AddDialogHandler>MultiSelect,MSButton3,OnClick,ClearList
AddDialogHandler>MultiSelect,MSButton4,OnClick,CleanList
AddDialogHandler>MultiSelect,MSButton5,OnClick,Move_Up
AddDialogHandler>MultiSelect,MSButton6,OnClick,Move_Down
AddDialogHandler>MultiSelect,MSButton7,OnClick,DoBrowse

Show>MultiSelect,r

// Do Somethin with the list
VBEVal>Space(8),padding
Let>MSG_WIDTH=600
StringReplace>%Selected_files%,%padding%,,TheSelected
Messagemodal>Do Somethin with myList%CRLF%%CRLF%%TheSelected% 

vbrun>Close
Exit

SRT>DoBrowse
let>hFlist=
//let>RP_ADMIN=1
SetDialogProperty>MultiSelect,MSListBox1,Text,%hFList%
SetDialogProperty>MultiSelect,MSButton7,DoBrowse,True
GetDialogProperty>MultiSelect,MSButton7,Filename,path
VBEval>checkState,Dstate
if>Dstate=0
vbrun>CreateRecordSet
endif
 vbrun>ShowSubFolders,%path%
 vbrun>GetList
 vbeval>recursion,hFList
 'Separate>%hFList%,||,hFList
 'vbrun>Close
SetDialogProperty>MultiSelect,MSListBox1,Text,%hFList%
//SetDialogProperty>MultiSelect,MSButton7,DoBrowse,False
//SetDialogProperty>MultiSelect,MSButton7,Visible,False
END>DoBrowse

SRT>CleanList
  StringReplace>%Selected_files%,--removed--%CRLF%,,Selected_files
  SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>CleanList

SRT>ClearList
  let>Selected_files=
  SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>ClearList

SRT>FileRem
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,remfile_list
Separate>Selected_files,CRLF,selected_items
GetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,rn
Separate>remfile_list,CRLF,rem_items
let>re=0
Repeat>re
  let>re=re+1
  StringReplace>%Selected_files%,rem_items_%re%,--removed--,Selected_files
Until>re,rem_items_count
SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>FileRem

SRT>FileAdd
GetDialogProperty>MultiSelect,MSListBox2,SelectedItems,file_list
let>Selected_files=%Selected_files%%CRLF%%file_list%
SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
StringReplace>%Selected_files%,;%CRLF%,,Selected_files
SetDialogProperty>MultiSelect,MSListBox3,Text,Selected_files
END>FileAdd

SRT>FolderSelect
 SDP>MultiSelect,MSButton1,Enabled,False
GetDialogProperty>MultiSelect,MSListBox1,SelectedItems,Selected_list
Separate>Selected_List,;,selected_items
VBEval>GetRecord(%selected_items_2%-1),RecordSet
Let>GFL_TYPE=0
GetFileList>%RecordSet%\*.%ext%,theList,CRLF
Separate>%theList%,%crlf%,FileArray
Let>i=0
Let>FList=
repeat>i
let>i=i+1
Separate>FileArray_%i%,\,nameList
let>name=nameList_%nameList_count%
VBEVal>Space(300),pad
Let>fPath=FileArray_%i%
Let>FList=%FList%%name%%pad%;%fPath%%CRLF%
Until>i,FileArray_Count
SetDialogProperty>MultiSelect,MSListBox2,Text,FList
END>FolderSelect

SRT>FileSelect
  SDP>MultiSelect,MSButton1,Enabled,True
END>FileSelect

SRT>Move_Up
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,False
GetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,rn
If>%rn%=0
Goto>end_of_up_sub
Else
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,rvo
Let>rn=%rn%-1
GoSub>swapItem
Endif
Label>end_of_up_sub
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,True
END>Move_Up

SRT>Move_Down
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,False
GetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,rn
If>%rn%=-1
Goto>end_of_down_sub
else
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,rvo
Let>rn=%rn%+1
GoSub>swapItem
Endif
Label>end_of_down_sub
SetDialogProperty>MultiSelect,MSListBox3,MultiSelect,True
END>Move_Down

SRT>swapItem
SetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,%rn%
GetDialogProperty>MultiSelect,MSListBox3,SelectedItems,rvn
StringReplace>%Selected_files%,%rvo%,Rp1,Selected_files
StringReplace>%Selected_files%,%rvn%,%rvo%,Selected_files
StringReplace>%Selected_files%,Rp1,%rvn%,Selected_files
SetDialogProperty>MultiSelect,MSListBox3,Text,%Selected_files%
SetDialogProperty>MultiSelect,MSListBox3,SelectedIndex,%rn%
END>swapItem

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts