MatchUp Object:Matchcode:Order of Operations
MatchUp Object Matchcode Interface Navigation | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Overview | |||||||||||
Order of Operations | |||||||||||
Mapping Information | |||||||||||
|
Creating Matchcodes Basic Steps
Using the Matchcode interface is not overly complicated but there are many options that must be considered for matchcodes and matchcode components.
These are the basic steps of a typical implementation of the Matchcode interface.
- Initialize the Matchcode interface and set the data path.
- The Matchcode interface does not require a License Key so this step is much simpler than with the other interfaces.
- Create a new matchcode.
- The CreateNewMatchcode function creates a new, blank matchcode for editing.
- Create new matchcode components.
- Matchcode components are created as class variables. Create an instance of the MatchcodeComponent for each component.
- Set the options for each matchcode component.
- Use the functions of the matchcode component class to select the options for the component type, size, matching strategy, swap pair, and to which combinations the component belongs.
- Add the components to the new matchcode.
- Use the AddMatchcodeItem function to add the component to the new matchcode. At this point, the Matchcode interface checks the component for errors.
- Save the changes to the matchcode file.
- The Matchcode interface can either save the changes to the original matchcode file or to a new copy of the file.
Creating Matchcodes Pseudocode Implementation
This is a simplified code sample written in pseudocode showing the creation of a basic matchcode using the Matchcode interface.
Initialize the Matchcode interface
Initialization consists of creating a new instance of the Matchcode class and connecting that instance to the data files. The Matchcode interface does not require a License Key, so many of the functions found in the other interfaces are not present here.
SET mc = NEW mdMUMatchcode CALL mc.SetPathToMatchUpFiles with PathToMatchUpFiles IF mc.ErrorNone == mc.InitializeDataFiles THEN PRINT "Initializing DataFiles..." PRINT "Confirm Init Non-Error: " + mc.GetInitializeErrorString ELSE PRINT "Init Error: " + mc.GetInitializeErrorString ENDIF
Create a new matchcode
A new matchcode requires a name. This program forces the users to keep entering a name until a valid name is entered.
REPEAT PRINT "Enter New Matchcode Name: " GET INPUT NewMatchCodeName CALL mc.CreateNewMatchcode with NewMatchCodeName RETURNING Created IF Created = 0 THEN PRINT "Could Not Create Matchcode!" UNTIL Created <> 0
Create new matchcode components
Matchcode components are created as instances of the MatchcodeComponent class. Another approach would be to create an array or simply create and add each component as part of a loop.
SET mcComp, mcComp2, mcComp3, mcComp4, mcComp5 = NEW mdMUMatchcodeComponent
Set the options for each matchcode component
Use the functions of the matchcode component class to select the options for the component type, size, matching strategy, swap pair, and to which combinations the component belongs.
CALL mcComp.SetComponentType WITH MatchCodeComponentType.Zip5 CALL mcComp.SetStart WITH MatchcodeStart.Left CALL mcComp.SetFuzzy WITH MatchcodeFuzzy.Exact CALL mcComp.SetSwap WITH MatchcodeSwap.NoSwap CALL mcComp.SetFieldMatch WITH MatchcodeFieldMatch.NoFieldMatch CALL mcComp.SetSize WITH 5 CALL mcComp.SetCombination WITH (MatchcodeCombination.Combo1 OR MatchcodeCombination.Combo2)
Add the components to the new matchcode
Use the AddMatchcodeItem function to add the component to the new matchcode. At this point, the Matchcode Editing Matchcode interface allows you to check for errors, when attempting to add this components.
CALL mc.AddMatchcodeItem WITH mcComp RETURNING mcCompAdded IF mcCompAdded <> 0 THEN PRINT "Component Added."
Repeat for each component
Repeat steps 4 & 5 for each component.
CALL mcComp2.SetComponentType WITH MatchCodeComponentType.Last CALL mcComp2.SetStart WITH MatchcodeStart.Left CALL mcComp2.SetFuzzy WITH MatchcodeFuzzy.AccurateNear CALL mcComp2.SetNear WITH 1 CALL mcComp2.SetSwap WITH MatchcodeSwap.NoSwap CALL mcComp2.SetFieldMatch WITH mcComp.BothBlankMatch CALL mcComp2.SetSize WITH 7 CALL mcComp2.SetCombination WITH (MatchcodeCombination.Combo1 OR MatchcodeCombination.Combo2) CALL mc.AddMatchcodeItem WITH mcComp2 RETURNING mcCompAdded IF mcCompAdd <> 0 THEN PRINT "Component Added"
Repeat until all five components have been created and added to the current matchcode.
Save the changes to the matchcode file
The Matchcode Editing Matchcode interface can either save the changes to the original matchcode file or to a new copy of the file.
CALL mc.Save
Reading Matchcodes Basic Steps
Reading the matchcode file is simpler in that it requires no thought about the rules for matchcodes, but it does require some programming to translate the values returned into meaningful information.
- Initialize the Matchcode interface and set the data path.
- The Matchcode interface does not require a License Key so this step is much simpler than with the other interfaces.
- Retrieve the matchcode.
- The FindMatchcode function loads the specified matchcode into memory.
- Begin cycling through every component in the matchcode.
- The Matchcode interface returns the number of components in the current matchcode. Use this number to loop through all of the components, assigning each component into to a MatchcodeComponent class variable.
- Retrieve the component settings.
- Call the MatchcodeComponent functions that return the settings for each component and, if necessary, translate them into meaningful information.
Reading Matchcodes Pseudocode Implementation
These functions would normally be used in conjunction with those for creating and modifying matchcodes but, for simplicity and clarity, this section will concentrate solely on showing how to retrieve the matchcode and component information.
Initialize the Matchcode interface
Initialization consists of creating a new instance of the Matchcode class and connecting that instance to the data files. The Matchcode interface does not require a License Key so many of the functions found in the other interfaces are not present here.
SET mc = NEW mdMUMatchcode CALL mc.SetPathToMatchUpFiles with PathToMatchUpFiles IF mc.ErrorNone == mc.InitializeDataFiles THEN PRINT "Initializing DataFiles..." PRINT "Confirm Init Non-Error: " + mc.GetInitializeErrorString ELSE PRINT "Init Error: " + mc.GetInitializeErrorString ENDIF
Retrieve a matchcode
The FindMatchcode function requires the name of an existing matchcode in the current matchcode file.
PRINT "Enter Existing Matchcode to Look Up: " INPUT MatchcodeName CALL mc.FindMatchcode WITH MatchcodeName RETURNING errorCode IF errorCode IS NOT 1 THEN PRINT "Matchcode can not be OPENED: " + errorCode END ROUTINE END IF
Begin cycling through every component in the matchcode
Use the GetMatchcodeItemCount function, determine how many components are present in the current matchcode.
FOR MatchcodeItem = 1 TO mc.GetMatchcodeItemCount CALL mc.GetMatchcodeItem with MatchcodeItem RETURNING mcComp
Retrieve the component settings
Begin calling the MatchcodeComponent functions to return the settings for each matchcode.
CALL mcComp.GetLabel RETURNING Label IF LABEL IS NOT EMPTY THEN PRINT LABEL CALL mcComp->GetComponentType RETURNING ComponentTypeName CASE ComponentTypeName OF 1: Type = "Prefix" 2: Type = "First" 3: Type = "Middle" 4: Type = "Last" 5: Type = "Suffix" 6: Type = "Gender" 7: Type = "FirstNickname" 8: Type = "MiddleNickname" 9: Type = "Title" 10: Type = "Company" 11: Type = "CompanyAcronym" 12: Type = "StreetNumber" 13: Type = "StreetPreDir" 14: Type = "StreetName" 15: Type = "StreetSuffix" 16: Type = "StreetPostDir" 17: Type = "POBox"
This is an incomplete list, but with a separate case for each component type, the program determines the component type and displays the name.
Other: Type = "UNDETERMINED" ENDCASE PRINT "Type:" + Type
Retrieve and display the size of the current component.
CALL mcComp->GetSize RETURNING Size : Print "Size: " + Size
Repeat the same basic procedure for the Component starting position.
CALL mcComp->GetStart RETURNING ComponentStart CASE OF ComponentStart 0x08: Start = "Left" 0x10: Start = "Right" 0x20: Start = "Pos:" 0x40: Start = "Word:" Other: Start = "UNKNOWN" ENDCASE PRINT "Start: " + Start
Repeat again for the fuzzy matching rule for the current component. The following is an incomplete list.
CALL mcComp->GetFuzzy RETURNING ComponentFuzzy CASE OF ComponentFuzzy 0x0000 : Fuzzy = "Exact" 0x0001 : Fuzzy = "SoundEx" 0x0002 : Fuzzy = "Phonetex" 0x0004 : Fuzzy = "Containment" 0x0008 : Fuzzy = "Frequency" 0x0010 : Fuzzy = "FastNear" 0x0020 : Fuzzy = "AccrNear" 0x0040 : Fuzzy = "Vowels" 0x0080 : Fuzzy = "Consonants" 0x0100 : Fuzzy = "Alphas" 0x0200 : Fuzzy = "Numerics" 0x0400 : Fuzzy = "FreqNear" Other: Fuzzy = "UNKNOWN" ENDCASE PRINT "Fuzzy Matching: " + Fuzzy
Repeat again for the blank field matching rules.
Call mcComp->GetFieldMatch RETURNING ComponentField CASE OF ComponentField 0: FieldMatch = "NO Blank" 0x0100: FieldMatch = "BothBlank" 0x0200: FieldMatch = "OneBlank" 0x0400: FieldMatch = "Initial" 0x0300: FieldMatch = "Both/One" 0x0500: FieldMatch = "Both/Init" 0x0600: FieldMatch = "Init/One" 0x0700: FieldMatch = "Both/One/Init" Other: FieldMatch = "UNKNOWN" ENDCASE PRINT "Blank Field Matching: " + Field
The process for getting the information about which combinations the component belongs to is somewhat more complicated. It involves using a logic AND operation to compare the value returned by the GetCombination function to each of the possible values shown in the Enumerations.
CALL mcComp->GetCombination RETURNING ComponentCombos SET CombinationsList to empty string IF ComponentCombos AND 0x0001 THEN Concatenate "1" TO CombinationsList ELSE Concatenate "." TO CombinationsList END IF IF ComponentCombos AND 0x0002 THEN Concatenate "2" TO CombinationsList ELSE Concatenate "." TO CombinationsList END IF IF ComponentCombos AND 0x0004 THEN Concatenate "3" TO CombinationsList ELSE Concatenate "." TO CombinationsList END IF
This snippet of code adds a digit for each combination that uses the component. Otherwise, it adds a period to represent a blank. Repeat the above structure for each possible value from the Enumerations.
IF ComponentCombos AND 0x8000 THEN Concatenate "F" TO CombinationsList ELSE Concatenate "." TO CombinationsList END IF PRINT "This component is used for these combinations: " + CombinationsList
Repeat for each component in the matchcode.
ENDFOR