Add Method of the IFPCExplicitLinkTranslationMappings Interface

The Add method creates a new FPCExplicitLinkTranslationMapping object in the collection and returns a reference to it.



  [in]   BSTR OriginalUrl,
  [in]   BSTR TranslatedUrl,
  [out]  IFPCExplicitLinkTranslationMapping** ppNewMapping


Required. BSTR that specifies the original URL in the new mapping.
Required. BSTR that specifies the translated URL in the new mapping.

Address of an interface pointer that on return points to the new IFPCExplicitLinkTranslationMapping interface created.

Return Value

This method can return one of the following:

[Visual Basic]


Function Add( _
  ByVal OriginalUrl As String, _
  ByVal TranslatedUrl As String _
) As FPCExplicitLinkTranslationMapping


Required. String that specifies the original URL in the new mapping.
Required. String that specifies the translated URL in the new mapping.

Return Value

This method returns a reference to an FPCExplicitLinkTranslationMapping object if successful. Otherwise, an error is raised that can be intercepted by using an error handler.

Example Code

This VBScript script adds user-defined (explicit) global link translation mappings for the local array from a user-specified file. Note that the text file must contain a list of mappings consisting of two strings separated by a tab character with each mapping on a separate line.
Option Explicit
'Define the constants needed
Const Error_FileNotFound = &H80070002
Const Error_FileAlreadyExits = &H800700B7
Const Error_NoProtocol = &HC00403E0
Const ForReading = 1
Sub Main(args)
	If(args.Count <> 1) Then
	End If
	AddGlobalMappings args(0)
End Sub
Sub AddGlobalMappings(fileName)
	' Create the root object.
	Dim root  ' The FPCLib.FPC root object
	Set root = CreateObject("FPC.Root")
	'Declare the other objects needed.
	Dim isaArray	' An FPCArray object
	Dim mappings	' An FPCExplicitLinkTranslationMappings collection
	Dim fso		 ' A FileSystem object
	Dim fileStream  ' A TextStream object
	Dim textRead	' A String
	Dim original	' A String
	Dim translated  ' A String
	DIm i		 ' An Integer
	Dim pos		 ' An Integer
	' Get references to the array object and the collection of user-defined
	' global mappings.
	Set isaArray = root.GetContainingArray()
	Set mappings = isaArray.ArrayPolicy.WebProxy.ExplicitLinkTranslationMappings
	Set fso = CreateObject("Scripting.FileSystemObject")
	On Error Resume Next
	Set fileStream = fso.OpenTextFile(fileName, ForReading)
	If Err.Number <> 0 Then
		WScript.Echo "The file specified could not be found."
	End If
	On Error GoTo 0
	' Clear the existing user-defined global mappings for the array
	' and then add the explicit global mappings from the file.
	WScript.Echo "Removing the existing user-defined global mappings..." 
	i = mappings.Count
	Do While i > 0
		mappings.Remove i
		i = i - 1	 
	WScript.Echo "Adding user-defined global mappings "  _ 
				 & "from the file " & fileName & "..."
	Do While fileStream.AtEndOfStream <> True
		textRead = fileStream.ReadLine
		If textRead <> "" Then
			pos = InStr(1, textRead, vbTab, vbTextCompare)
			If (pos <> 0) Then
				original = Left(textRead, pos - 1)
				translated = Right(textRead, Len(textRead) - pos)
				On Error Resume Next
				mappings.Add original, translated
				If Err.Number = Error_FileAlreadyExits Then
					WScript.Echo "A duplicate mapping for " & original _
								 & " was ignored."
				ElseIf Err.Number = Error_NoProtocol Then
					WScript.Echo "A mapping without a valid protocol was ignored."
				End If
				On Error GoTo 0
			End If
		End If
	isaArray.Save True
	WScript.Echo "Done!"
End Sub 
Sub Usage()
	WScript.Echo "Usage:" & VbCrLf _
		& "  CScript " & WScript.ScriptName & " FileName" & VbCrLf _
		& "" & VbCrLf _
		& "  FileName  - Text file containing a list of mappings" 
End Sub


The URLs specified in the OriginalUrl and TranslatedUrl parameters must specify HTTP or HTTPS as the protocol.


Client Requires Windows Vista or Windows XP.
Server Requires Windows Server 2008.
Version Requires Forefront Threat Management Gateway (TMG).

Declared in Msfpccom.idl.


Requires Msfpccom.dll.

See Also


Send comments about this topic to Microsoft

Build date: 11/30/2009

© 2008 Microsoft Corporation. All rights reserved.