Preselected file is not added to selection by FROMSCRIPT


if I run the following script after I selected a file in the tab all files are selected except for the selected file. All files only get selected if no file is selected in the tab. Is there a way of adding the selected file to the selection or do I make a mistake here? Thank you for your help

Function OnClick ( ByRef ClickData )
	Set cmd = ClickData.Func.Command
	Set AllFiles = ClickData.Func.SourceTab.Files
	Set SelectedFiles = ClickData.Func.SourceTab.selected_files
	For Each Selected_file In Allfiles
		filePath = Selected_file.realpath 
		If InStr(1, filePath, "lib://") = 1 Then
			filePathlogfile = DOpus.FSUtil.Resolve(filePath)
		End If
	cmd.RunCommand("Select FROMSCRIPT")
End Function
Function OnClick ( ByRef ClickData )
    Set cmd = clickData.func.command
    cmd.deselect = false ' Prevent automatic deselection