' ----------------------------------------------
' Tahiti - Examples
' Copyright LightComp v.o.s. 2009
' ----------------------------------------------
'
' Create document in the Tahiti and insert TPKG
' as a page
'
'

set tahiti=CreateObject("LightComp.Tahiti")

On Error Resume Next
set domain=tahiti.domains.item("test.ept")
On Error Goto 0
if IsEmpty(domain) then
  tahiti=null
  MsgBox "Please add domain test.ept."
  WScript.Quit 1
end if
if domain.status<>2 then
  MsgBox "Domain test.ept is not active. Please run Tahiti with this domain in online or offline mode."
  WScript.Quit 1
end if

set component = domain.components.item("DocumentManager")
set docManager = component.GetInterface()

Dim doc
On Error Resume Next
set doc = docManager.CreateDocument("Letter",FALSE)
On Error Goto 0
if IsEmpty(doc) then
  MsgBox "Operation canceled."
else
  ' File path
  fileName = Left(WScript.ScriptFullName, LEN(WScript.ScriptFullName)-LEN(WScript.ScriptName)) &"dopis.tpkg"
  set attrs = doc.Attributes
  ' Set attributes
  set attr = attrs.Item("Description")
  attr.value = fileName
  set attr = attrs.Item("FileNumber")
  attr.value = Now
  set attr = attrs.AddAttribute("Tahiti.TPKG.Logo", "0")
  doc.AddPage fileName, "tahiti.package"

  '
  ' Format attributes
  '
  set attrs = doc.Attributes
  dim attrDescr
  attrDescr = ""
  For Each a In attrs
    attrDescr = attrDescr & vbCrLf & a.name & "=" & a.value
  Next
  MsgBox "Document created, Domain: " & doc.repository.domain.configuration.getValue("Connection.Name") & _
	vbCrLf & "Attributes Count: " & attrs.Count & vbCrLf & attrDescr
end if

