Download Example File
- This example shows the different ways you can work with the built-in accounts of the plug-in.
- The first example shows how to manually create and edit the accounts.
- The second example shows how to use one account to allow changing FTP servers dynamically.
- The final example shows the available functions for complete automation of managing accounts.
The first way to work with the accounts is by manual creation and configuration. If you only use a few FTP servers or only need to use the plug-in on a few computers, this is the easiest way to setup the plug-in.
To do this, you will need to use the FTPit_ConfigureAccount function. You can either copy and paste the button from the example into your database, or create a new button and then set the “Button Setup” to a Set Field script step with a calculation of the following function. You could also do this with a script instead of a button step.
The Account Configuration Dialog only creates accounts on your local computer. If you need to use the plug-in on a second computer, you will need to re-create the accounts. Once the accounts are created, use the FTPit_Connect ( “Account Name” ) function to connect to an account.
To work with multiple accounts and automate this process, see the other examples in this database.
Automated Single Account
The idea behind this method is to create a single account, and change the settings in it each time you need to change FTP servers. This method is similar to how the classic FTPit plug-in worked, so if you used that plug-in and want to use FTPit Pro in the same way, this is the method for you.
Your script will first need to create an Account, and you can name it whatever you like. This is done using the FTPit_AddAccount function. The script then needs to set the Account details using the FTPit_SetAccountOption function. The Set Field calculation in your script would look like the following.
FTPit_AddAccount( “FTP_Server” ) & “¶” & FTPit_SetAccountOption( “FTP_Server”; “Host” ; FTP::Host) & “¶” & FTPit_SetAccountOption( “FTP_Server”; “Port” ; FTP::Port) & “¶” & FTPit_SetAccountOption( “FTP_Server”; “Username” ; FTP::Username ) & “¶” & FTPit_SetAccountOption( “FTP_Server”; “Password” ; FTP::Password )
If you added this calculation to the start of your FTP scripts, you could then dynamically change FTP servers as needed based on fields or other criteria.
Automated Multiple Accounts
The final method is to create an account for each FTP server. The functions provided allow you to check what accounts currently exist, create new accounts, delete accounts, set account details, and retrieve account details.
FTPit_GetAccountNames - Returns the names of all currently defined accounts.
FTPit_AddAccount( AccountName ) - Adds a new account with the specified name.
FTPit_RemoveAccount( AccountName ) - Removes an account with the specified name.
FTPit_SetAccountOption( AccountName ; OptionName ; OptionValue ) - Sets options in an account.
FTPit_GetAccountOption( AccountName ; OptionName ) - Retrieves options from an account.
Using these functions you could write a script to check the existing accounts, create accounts that do not exist, and add the account options. If you keep a table of FTP Server details, these functions will allow you to loop through your FTP Server records and create/update the FTPit Pro accounts.
More information about the functions can be found in the Functions section.