Customization > Extensibility Through Profiles, Stereotypes, Tag Definitions and Scripts > Script functions, objects and attributes > Script templates > Script template for diagram toolbar button scripts for links
  
Script template for diagram toolbar button scripts for links
This topic provides a template of the empty functions that can be used in a diagram toolbar button script for links.
You can copy the script template text that follows from this topic to the Script property in Modeler. If you want single line spacing, copy the following text from this topic to Notepad, and then copy the text from Notepad to Modeler.
Key:
Remarked variable names at the top of the file are available in all functions underneath except where stated.
Remarked variable names immediately above functions are only available in those functions (or subfunctions called).
The comment line '---Context change--- indicates that script is unloaded and reloaded here between function calls - this means that script scoped variables cannot be used to transfer data between functions separated by one of these comment lines, and other methods (such as helper dlls) should be used in the (fairly rare) situation that this is needed.
Option Explicit

'Studio'
Projects
'ActiveProject
'Dictionary (except for OnFinished)
'CurrentScript
'Diagram - the active diagram
'Following 4 variables apply to start line click in ValidOrigin and end line click otherwise
'Script.Flags - Bits indicating mouse button, Shift and Ctrl keys pressed (see Help)
'Script.AdditionalInfo - Only matters for Activity Partitions otherwise 0 (see Help)
'Script.PasteAtX - Absolute X posn mouse clicked
'Script.PasteAtY - Absolute Y posn mouse clicked

'Script.HitSymbol - the item clicked on the diagram to start the line
'Script.Paste
Function ValidOrigin()
ValidOrigin=False
ValidOrigin=True
End Function

'---Context change---

'Script.OriginSymbol - the item clicked on the diagram to start the line
'Script.HitSymbol - the item clicked on the diagram to end the line
Function ValidDestination()
ValidDestination=False
ValidDestination=True
End Function

'---Context change---

'Override the popup menu to choose from existing relationships
'Leave commented or delete if you want the default functionality
'Function SelectObject()
'SelectObject=False
'In a given invocation you should either
'Script.AddResultObject <DictItem>
'or
'Script.NewItemName = <nonnullfornewrelationship>
'SelectObject=True
'End Function

'---Context change---

'Script.OriginSymbol - the item clicked on the diagram to start the line
'Script.DestinationSymbol - the item clicked on the diagram to end the line
'NewSymbol - the symbol being added to the diagram
'DictItem - the dictionary item being added to a diagram
'Script.AddedSymbol - Only for Custom Node/Link scripts programmer must set
'Script.SelectedDictionaryItem - Only for Custom Node/Link scripts gives oItem (if any)
'set by SelectObject() Script.AddResultObject(oItem) call
Function OnFinished()
OnFinished=False
OnFinished=True
End Function