'
' Example script for 2BrightSparks SyncBackPro V8 that adds
' extra columns to the Differences window.
'
' SBLang=Basic
'
' 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 = SCRIPTTYPE_RUN
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
  StoredName = ""
  FSize = 0
  Attr = 0
  Hash = ""
  ModDateTime = Now
  CreateDateTime = Now
  NTFSSec = ""
  Exists = FALSE
  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 = CDate(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
