Hello,
I want to write a script shich selects files first based on a filter and then adds files to that depending which files the filter selected.
This is what I've come up with so far
[code]Function OnClick ( ByRef ClickData )
ClickData.Func.Command.RunCommand("Select ""Interrupted DVB-Files"" Filter")
number_selected_files = DOpus.Listers.LastActive().ActiveTab.selstats.selfiles
Dim Selected_by_filter
Dim Total_files_To_select
Dim slected_file
If number_selected_files = 0 Then
Set dlg = DOpus.Dlg
dlg.Window = DOpus.Listers(0)
dlg.message = "No matching files were found"
dlg.title = "Warnung"
dlg.icon = "information"
dlg.buttons = "OK"
dlg.Show
Else
'Selection = DOpus.Listers.LastActive().ActiveTab.selected_files
Set Selected_by_filter = DOpus.NewVector
Set Total_files_To_select = DOpus.NewVector
Selected_by_filter.assign(ClickData.func.sourcetab.selected_files)
Total_files_To_select.assign(ClickData.func.sourcetab.selected_files)
Set dlg = DOpus.Dlg
dlg.Window = DOpus.Listers(0)
dlg.message = Selected_by_filter.count
dlg.title = "Info"
dlg.icon = "information"
dlg.buttons = "OK"
dlg.Show
'Set All_selected_Transportstreams = ClickData.func.sourcetab.selected_files.name_stem
'For i=0 To (All_selected_Transportstreams.count) -1
' Filename = ClickData.func.sourcetab.selected_files(i).name
' txtname = Replace(Filename, ".ts",".txt")
' Logname = Replace(Filename, ".ts",".log")
'Set dlg = DOpus.Dlg
'dlg.Window = DOpus.Listers(0)
'dlg.message = Logname
'dlg.title = "Warnung"
'dlg.icon = "information"
'dlg.buttons = "OK"
'dlg.Show
'Next
For Each Selected_file In Selected_by_filter
Filename = Selected_file.name
'Filename = Selected_file.realpath.path
txtname = Replace(Filename, ".ts",".txt")
Total_files_To_select.push_back(txtname)
Logname = Replace(Filename, ".ts",".log")
Total_files_To_select.push_back(Logname)
Next
' add the vector the the selected files
Clickdata.Func.Command.AddFiles(Total_files_To_select)
Clickdata.Func.Command.RunCommand("Select FROMSCRIPT")
Set dlg = DOpus.Dlg
dlg.Window = DOpus.Listers(0)
dlg.message = Total_files_To_select.count
dlg.title = "Info"
dlg.icon = "information"
dlg.buttons = "OK"
dlg.Show
End If
End Function
[/code]
The script crashes at the lines where the files with their filenames in the vector Total_files_To_select should be added to the selection. Most probably I have a misunderstanding of what addfiles does really do. Can anybody help?
Thanks in advance
P.S. I tested the script in a windows library. The Dialog Boxes are just for debugging purposed