'
' Example script for 2BrightSparks SyncBackPro that adds
' extra columns to the Differences window.
'
' SBLang=VBScript
'
' http://www.2BrightSparks.com/
'

'
' This is a runtime script
'
Function Description(ByRef ScriptType)
  Description = "Adds creation date and time, attributes and NTFS security columns"
  ScriptType = 2
End Function

'
' Tell SyncBack how many columns we are adding to the Differences window
'
Function RunDiffColumnsCount()
  RunDiffColumnsCount=6
End Function

'
' The column captions
'
Function RunDiffColumnTitle(Col, Width)
  If Col = 0 Then
    RunDiffColumnTitle = "Created (" + SBRunning.LeftName + ")"
    Width = 150
  ElseIf Col = 1 then
    RunDiffColumnTitle = "Created (" + SBRunning.RightName + ")"
    Width = 150
  ElseIf Col = 2 then
    RunDiffColumnTitle = "Attrs (" + SBRunning.LeftName + ")"
    Width = 150
  ElseIf Col = 3 then
    RunDiffColumnTitle = "Attrs (" + SBRunning.RightName + ")"
    Width = 150
  ElseIf Col = 4 then
    RunDiffColumnTitle = "Security (" + SBRunning.LeftName + ")"
    Width = 150
  ElseIf Col = 5 then
    RunDiffColumnTitle = "Security (" + SBRunning.RightName + ")"
    Width = 150
  Else
    RunDiffColumnTitle = ""
    Width = 0
  End If
End Function

'
' The text that goes into each column
'
Function RunDiffColumnText(Col, IsFile, Filename)
  ' Left or right?
  Select Case Col
  Case 0, 2, 4
    IsLeft = true
  Case Else
    IsLeft = false
  End Select

  ' Get details of file or folder
  If IsFile then
    If not SBRunning.GetFileDetailsEx(Filename, IsLeft, StoredName, FSize, Attr, Hash, ModDateTime, CreateDateTime, NTFSSec, Exists) then
      RunDiffColumnText = ""
      Exit Function
    End If
  Else
    If not SBRunning.GetFolderDetailsEx(Filename, IsLeft, StoredName, Attr, ModDateTime, CreateDateTime, NTFSSec, Exists) then
      RunDiffColumnText = ""
      Exit Function
    End If
  End If

  ' Return column text
  Select Case Col
  Case 0, 1
    RunDiffColumnText = CreateDateTime
  Case 2
    RunDiffColumnText = SBRunning.LeftAttribsToStr(Attr)
  Case 3
    RunDiffColumnText = SBRunning.RightAttribsToStr(Attr)
  Case 4, 5
    RunDiffColumnText = NTFSSec
  Case Else
    RunDiffColumnText = ""
  End Select
End Function
