Developer Documentation Library > Data Model > Extending the UNICOM Intelligence Data Model > Working with the Alias Map component > Examples of configuring the Generator > 7: Multiple aliases
 
7: Multiple aliases
This topic provides an example of using the multiple alias feature to create four groups of aliases from one input text.
VBScript example
Private Sub Example_7a()
Dim MyConfiguration As MRALIASMAPLib.IGeneratorConfiguration
Dim MyGenerator As New MRALIASMAPLib.Generator
Dim MyMapper As New MRALIASMAPLib.Mapper
Dim MyAlias As MRALIASMAPLib.Alias
Dim MyFreeCounter As MRALIASMAPLib.Counter
Dim MyRule As MRALIASMAPLib.Rule
Dim MyAliasCollection As MRALIASMAPLib.AliasCollection
Dim i As Integer
Dim j As Integer
Dim MyCounter As MRALIASMAPLib.Counter
Dim First As Integer
Dim Last As Integer

Set MyConfiguration = MyGenerator.Configuration

MyConfiguration.Clear
Set MyRule = MyConfiguration.Rules.AddNew("$")
MyRule.Replacements.AddOperator ropFreeCounter
MyConfiguration.FreeCounters.AddNew
Set MyFreeCounter = MyConfiguration.FreeCounters.Item(0)
MyFreeCounter.MaxCount = 3
Set MyRule = MyConfiguration.Rules.AddNew("$")
MyRule.Replacements.AddOperator ropAutoCounter
MyConfiguration.AutoCounters.AddNew
Set MyCounter = MyConfiguration.AutoCounters.Item(0)
MyCounter.Charset.Clear
First = AscW("A")
Last = AscW("Z")
MyCounter.Charset.AddRange First, Last
MyCounter.Prefix = "~"
MyCounter.ExpandWithZero = True

Set MyMapper.Generator = MyGenerator
Set MyAlias = MyMapper.CreateAlias("UNICOM Intelligence")

For j = 0 To 3
Set MyAlias = MyMapper.CreateAlias("UNICOM Intelligence")
Set MyAliasCollection = MyMapper.CreateMultipleAliases(MyAlias.Name)

For i = 0 To MyAliasCollection.Count - 1
Debug.Print MyAliasCollection.Item(i).Name
Next i
Next j
End Sub
mrScript example
Sub Example_7a()
Dim MyConfiguration, MyGenerator, MyMapper, MyAlias, MyFreeCounter, MyRule, MyAliasCollection, MyCounter, i, j, First, Last
Set MyGenerator = CreateObject("MRALIASMAP.Generator")
Set MyMapper = CreateObject("MRALIASMAP.Mapper")
Set MyAlias = CreateObject("MRALIASMAP.Alias")
Set MyFreeCounter = CreateObject("MRALIASMAP.Counter")
Set MyRule = CreateObject("MRALIASMAP.Rule")
Set MyAliasCollection = CreateObject("MRALIASMAP.AliasCollection")
Set MyCounter = CreateObject("MRALIASMAP.Counter")

Set MyConfiguration = MyGenerator.Configuration

MyConfiguration.Clear()
Set MyRule = MyConfiguration.Rules.AddNew("$")
MyRule.Replacements.AddOperator(3 '!ropFreeCounter!')
MyConfiguration.FreeCounters.AddNew()
Set MyFreeCounter = MyConfiguration.FreeCounters[0]
MyFreeCounter.MaxCount = 3
Set MyRule = MyConfiguration.Rules.AddNew("$")
MyRule.Replacements.AddOperator(2 '!ropAutoCounter!')
MyConfiguration.AutoCounters.AddNew()
Set MyCounter = MyConfiguration.AutoCounters[0]
MyCounter.Charset.Clear()
First = AscW("A")
Last = AscW("Z")
MyCounter.Charset.AddRange(First, Last)
MyCounter.Prefix = "~"
MyCounter.ExpandWithZero = True

Set MyMapper.Generator = MyGenerator
Set MyAlias = MyMapper.CreateAlias("UNICOM Intelligence")

For j = 0 To 3
Set MyAlias = MyMapper.CreateAlias("UNICOM Intelligence")
Set MyAliasCollection = MyMapper.CreateMultipleAliases(MyAlias.Name)

For i = 0 To MyAliasCollection.Count - 1
Debug.Log(MyAliasCollection[i].Name)
Next
Next
End Sub
Results
Here are the results:
UNICOM Intelligence~A1
UNICOM Intelligence~A2
UNICOM Intelligence~A3
UNICOM Intelligence~B1
UNICOM Intelligence~B2
UNICOM Intelligence~B3
UNICOM Intelligence~C1
UNICOM Intelligence~C2
UNICOM Intelligence~C3
UNICOM Intelligence~D1
UNICOM Intelligence~D2
UNICOM Intelligence~D3
See also
1: Simple example
2: Avoiding duplicates
3: Configuring the counter
4: Further examples of configuring the counter
5: Short aliases
6: Complete examples
Examples of configuring the Generator