Adam
05-26-2004, 01:48 PM
All three of our HTTP actions have the option of using a table that contains the user's proxy information. The function below will accept the user's proxy information obtained from Input objects and return a table of these values.
This is the function code:
-- This function will test the variables that were provided and then
-- populate the table with valid data
function GenerateProxyTable(UserName,Password,ServerAddress ,ServerPort)
-- This creates the default table
ProxyTable = {PUserName = "",PPassword = "",PServerAddress = "",PServerPort = 0};
-- Make sure that there is data
if UserName ~= "" then
-- Add the value to the table
ProxyTable.PUserName = UserName;
end
-- Make sure that there is data
if Password ~= "" then
-- Add the value to the table
ProxyTable.PPassword = Password;
end
-- Make sure that there is data
if ServerAddress ~= "" then
-- Add the value to the table
ProxyTable.PServerAddress = ServerAddress;
end
-- Convert the string to a number
tempNum = String.ToNumber(ServerPort);
-- Make sure that there is data
if tempNum ~= 0 then
-- Add the value to the table
ProxyTable.PServerPort = tempNum;
end
-- Return the generated table
return ProxyTable;
end
You would then call this function using the following code:
-- Get the values from the Input objects
Name = Input.GetText("UserName");
Pass = Input.GetText("Password");
Addr = Input.GetText("Address");
Port = Input.GetText("Port");
-- Pass these values to the GenerateProxyTable function
ProxyInfo = GenerateProxyTable(Name,Pass,Addr,Port);
-- Show a dialog that shows the saved data.
Dialog.Message("Stored Proxy Info","User Name = "..ProxyInfo.PUserName.."\nPassword = "..ProxyInfo.PPassword.."\nAddress = "..ProxyInfo.PServerAddress.."\nPort = "..ProxyInfo.PServerPort);
The table returned can now be used with any of the following functions:
HTTP.Download()
HTTP.Submit()
HTTP.TestConnection()
Please download the attached file to see this example in action.
This is the function code:
-- This function will test the variables that were provided and then
-- populate the table with valid data
function GenerateProxyTable(UserName,Password,ServerAddress ,ServerPort)
-- This creates the default table
ProxyTable = {PUserName = "",PPassword = "",PServerAddress = "",PServerPort = 0};
-- Make sure that there is data
if UserName ~= "" then
-- Add the value to the table
ProxyTable.PUserName = UserName;
end
-- Make sure that there is data
if Password ~= "" then
-- Add the value to the table
ProxyTable.PPassword = Password;
end
-- Make sure that there is data
if ServerAddress ~= "" then
-- Add the value to the table
ProxyTable.PServerAddress = ServerAddress;
end
-- Convert the string to a number
tempNum = String.ToNumber(ServerPort);
-- Make sure that there is data
if tempNum ~= 0 then
-- Add the value to the table
ProxyTable.PServerPort = tempNum;
end
-- Return the generated table
return ProxyTable;
end
You would then call this function using the following code:
-- Get the values from the Input objects
Name = Input.GetText("UserName");
Pass = Input.GetText("Password");
Addr = Input.GetText("Address");
Port = Input.GetText("Port");
-- Pass these values to the GenerateProxyTable function
ProxyInfo = GenerateProxyTable(Name,Pass,Addr,Port);
-- Show a dialog that shows the saved data.
Dialog.Message("Stored Proxy Info","User Name = "..ProxyInfo.PUserName.."\nPassword = "..ProxyInfo.PPassword.."\nAddress = "..ProxyInfo.PServerAddress.."\nPort = "..ProxyInfo.PServerPort);
The table returned can now be used with any of the following functions:
HTTP.Download()
HTTP.Submit()
HTTP.TestConnection()
Please download the attached file to see this example in action.