'	This file contains a number of VBScript functions to
'	utilize SDI via its Automation interface.  This file is
'	provided as an example and does not implement all of 
'	SDI's features.  All of the Functions return False if
'	they fail.  The end of this file contains a brief script
'	which uses these functions.  This sample was written and
'	tested using Microsofts Windows Scripting Host which can
'	be found at the following location:
'	http://www.microsoft.com/scripting

Function ftpConnect(objSDI,strServer,strUsername,strPassword)
	If objSDI.ftp("open",strServer) = False Then
		ftpConnect = False
		Exit Function
	End If

	If objSDI.ftp("username",strUsername) = False Then
		ftpConnect = False
		Exit Function
	End If

	If objSDI.ftp("password",strPassword) = False Then
		ftpConnect =  False
		Exit Function
	End If

	ftpConnect = True
End Function

Function ftpPut(objSDI,strLocalFile,strRemoteFile)
	If objSDI.ftp("remotepath",strRemoteFile) = False Then
		ftpPut = False
		Exit Function
	End If

	If objSDI.ftp("put",strLocalFile) = False Then
		ftpPut = False
		Exit Function
	End If

	ftpPut = True
End Function

Function ftpGet(objSDI,strRemoteFile,strLocalFile)
	If objSDI.ftp("localpath",strLocalFile) = False Then
		ftpGet = False
		Exit Function
	End If

	If objSDI.ftp("get",strRemoteFile) = False Then
		ftpGet = False
		Exit Function
	End If

	ftpGet = True
End Function

Function ftpBinary(objSDI)
	If objSDI.ftp("binary","") = False Then
		ftpBinary = False
		Exit Function
	Else
		ftpBinary = True
		Exit Function
	End If

	ftpBinary = True
End Function

Function ftpAscii(objSDI)
	If objSDI.ftp("ascii","") = False Then
		ftpAscii = False
		Exit Function
	Else
		ftpAscii = True
		Exit Function
	End If

	ftpAscii = True
End Function

Function ftpDisconnect(objSDI)
	If objSDI.ftp("close","") = False Then
		ftpDisconnect = False
		Exit Function
	Else
		ftpDisconnect = True
		Exit Function
	End If

	ftpDisconnect = True
End Function

Sub displayError(objSDI)
	MsgBox(objSDI.GetLastError())
End Sub


'	Sample script using VBScript functions

Dim sdi
Set sdi = CreateObject("SDI32.Application")

If ftpConnect(sdi,"ftp.testserver.com","anonymous","test@testserver.com") = False Then
	displayError(sdi)
Else
	ftpDisconnect(sdi)
End If
