Sample VBScript Program

Top  Previous  Next

 

Robo-FTP may be called from VBScript (VBS) programs. The following is an example VBS program that loads Robo-FTP, logs on to the default FTP site, retrieves and displays the value of an internal Robo-FTP variable, and then logs off the site.

 

' Instantiate a Robo-FTP object

' -----------------------------

Set FTPReq = Createobject("RoboFTPAutomation.Automate")

 

If err.number <> 0 then

  msgbox "Failed to create COM object!"

  Wscript.quit 1

End If

 

' Set session properties and open session

' ---------------------------------------------

ResultCode = FTPReq.RoboStartSession("Sample", True, False, "")

 

If ResultCode <> -1 then

  msgbox "RoboStartSession Failed!" & vbCrLf & "Return value: " & ResultCode

  FTPReq.RoboEndSession

  Wscript.quit 2

End If

 

' log on to default site

' ----------------------

cmdString = "FTPLOGON"

ResultCode = FTPReq.RoboSendCommand(cmdString, 600)

 

' get the last error

' ------------------

msgbox "Value of %lasterror = " & FTPReq.RoboGetVBSVariable("%lasterror")

 

 

' log off the site

' ----------------

cmdString = "FTPLOGOFF"

ResultCode = FTPReq.RoboSendCommand(cmdString, 600)

 

' end Robo-FTP session and exit

' -----------------------------

FTPReq.RoboEndSession

msgbox "Done"

Wscript.Quit 0

 

 

See also: COM/OLE Operational Overview, COM Programming Reference