I try to re-use code as much as possible, and I tend to pass a lot of parameters. When connecting to a server, I pass the transfer_protocol, server_name, port_number, username, and password.
Within a script, I can assign the parameters for everything except setProtocol():
# getParam(3) - ftp protocol
# getParam(4) - ftp server name
# getParam(5) - ftp server port
# getParam(6) - ftp server username
# getParam(7) - ftp server password
setProtocol(getParam(3)) # This fails
setPort(getParam(5))
if (openHost(getParam(4),getParam(6),getParam(7)) != "OK")
I have to do a workaround:
if (getParam(3) == "FTP")
setProtocol(FTP)
endif
if (getParam(3) == "FTPS")
setProtocol(FTPS)
endif
if (getParam(3) == "FTPS_EXPLICIT")
setProtocol(FTPS_EXPLICIT)
endif
if (getParam(3) == "FTPS_EXPLICIT_ENCRYPT_DATA")
setProtocol(FTPS_EXPLICIT_ENCRYPT_DATA)
endif
if (getParam(3) == "FTPS_IMPLICIT")
setProtocol(FTPS_IMPLICIT)
endif
if (getParam(3) == "SFTP")
setProtocol(SFTP)
endif
What would be helpful is something like:
Within a script, I can assign the parameters for everything except setProtocol():
# getParam(3) - ftp protocol
# getParam(4) - ftp server name
# getParam(5) - ftp server port
# getParam(6) - ftp server username
# getParam(7) - ftp server password
setProtocol(getParam(3)) # This fails
setPort(getParam(5))
if (openHost(getParam(4),getParam(6),getParam(7)) != "OK")
I have to do a workaround:
if (getParam(3) == "FTP")
setProtocol(FTP)
endif
if (getParam(3) == "FTPS")
setProtocol(FTPS)
endif
if (getParam(3) == "FTPS_EXPLICIT")
setProtocol(FTPS_EXPLICIT)
endif
if (getParam(3) == "FTPS_EXPLICIT_ENCRYPT_DATA")
setProtocol(FTPS_EXPLICIT_ENCRYPT_DATA)
endif
if (getParam(3) == "FTPS_IMPLICIT")
setProtocol(FTPS_IMPLICIT)
endif
if (getParam(3) == "SFTP")
setProtocol(SFTP)
endif
What would be helpful is something like:
Code: Select all
if (setProtocol(getParam(3)) != OK)