Tags, Assets and Templates > Creating and Editing Tags > Built-in Tag Types > Reference Tags
  
Reference Tags
Reference Tags allows dynamic addressing of the variables.
The concept is closer to the concept of References in .NET programming, more than the old C++ pointers. The reason is that a Reference tag, like the .NET references, are TYPED; that means that when creating a Reference Tag, you need to define to which tag type or tag templates the referent will be pointing to. Like the .NET References and unlike the C++ pointers a Reference Tag cannot be defined to point to invalid memory areas that would cause errors in the application.
The target Type for Reference types is defined at the Parameters columns.
The fact that it is a typed reference brings advantages both in Engineering and Runtime. In Engineering it allows Intellisense to directly browse the members of the template, when the reference it pointing to a template; In the runtime it allows string data validation.
All Reference Tags have an additional runtime attribute that is the link, which specifies the tag, during the runtime execution that the reference will be lined.
Essentially the Link property is a string property that should receive the target tag name before using the reference tag. You can assign a string directly or by using a string expression, but the best way to set the Link property is to use the Method GetName(), which will create the string based on the current tag name. This way, you can rename the tag without having to search the strings. It also shows the tag names linked on the cross-reference utility.
An example project (ReferenceTags) ships with FactoryStudio.
Examples
@Tag.Reference1.Link = @Tag.TagName.GetName() (VB)
@Tag.Reference1.Link = @Tag.TagName.GetName(); (C#)
@Tag.Reference1.Link = “Tag.TagName” (C#)
@Tag.Reference1.Link = “Tag.TagNa” + “me”; (C#)
 
*Note: The reason to use the methods GetName() instead of using directly the strings “”, is even it is an allowed syntax, when using the method GetName() you retain the benefits of Cross-Reference and Refactoring, that would be possible if you string assignments or expressions.