Repository.Variable.AddVariable: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:APIBreadcrumb|10|Repository}}
{{Template:Repository.AddVariable.Cmt}} {{Template:BooleanReturn.Cmt}}
{{Template:API}}
Saves a new '''[[CVariable Class|cVariable]]''' object to the Synthesis repository. Returns a '''Boolean''' value; when true, indicates that the variable now exists in the repository.


==Syntax==
== Syntax ==
*AddVariable( var {{APIPrefix|As}}[[cVariable Class|cVariable]] ){{APIPrefix|As Boolean}}
''object''.'''Variable.AddVariable(''var'')'''


Parameters:
where ''object'' is a variable that represents a Repository object.
:''var'': The [[cVariable Class|cVariable]] to add.


== Usage Example ==
=== Parameters ===
  {{APIComment|'Declare a new repository connection object.}}
{| {{APITable}}
   Dim MyRepository As New Repository
|-
    
|var{{APIParam|Required}}||The '''[[CVariable Class|cVariable]]''' object to be added.
  {{APIComment|'Connect to the Synthesis repository.}}
|}
   Dim Success As Boolean = False
 
   Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
 
    
== Example ==
  {{APIComment|'Set a first available project as current.}}
'''VBA'''
  MyRepository.Project.SetCurrentProject(0)
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...'Add code to connect to a Synthesis repository.}}
{{APIComment|'Create a new variable. The following example creates a variable named "MyNewVariable".}}
   {{APIPrefix|Dim}} newVariable {{APIPrefix|As New}} cVariable
   NewVariable.Name = "MyNewVariable"
  {{APIComment|'Add the new variable to project #1. The variable will be visible in the Synthesis repository upon refresh.}}
   MyRepository.Project.SetCurrentProject(1) 
   {{APIPrefix|Call}} MyRepository.Variable.AddVariable(NewVariable)
 
'''VB.NET'''
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...'Add code to connect to a Synthesis repository.}}
{{APIComment|'Create a new variable. The following example creates a variable named "MyNewVariable".}}
  {{APIPrefix|Dim}} newVariable {{APIPrefix|As New}} cVariable ("MyNewVariable")
   
   
{{APIComment|'Declare a new cVariable.}}
  {{APIComment|'Add the new variable to project #1. The variable will be visible in the Synthesis repository upon refresh.}}
  Dim newVariable As New cVariable("NewVariable1")
   MyRepository.Project.SetCurrentProject(1) 
 
   MyRepository.Variable.AddVariable(newVariable)
  {{APIComment|'Add the new variable to the repository.}}
   Dim SuccessAddVariable As Boolean
   SuccessAddVariable = MyRepository.Variable.AddVariable(newVariable)

Revision as of 23:16, 14 July 2015

Member of: SynthesisAPI10Repository

APIWiki.png


Saves a new cVariable object to the Synthesis repository. Returns a Boolean value; when true, indicates that the variable now exists in the repository.

Syntax

object.Variable.AddVariable(var)

where object is a variable that represents a Repository object.

Parameters

Name Description
varborder="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse; text-align: left; cellborder"
Name Status The cVariable object to be added.


Example

VBA

 Dim MyRepository As New Repository
 ...'Add code to connect to a Synthesis repository. 

 'Create a new variable. The following example creates a variable named "MyNewVariable". 
 Dim newVariable As New cVariable
 NewVariable.Name = "MyNewVariable"

 'Add the new variable to project #1. The variable will be visible in the Synthesis repository upon refresh. 
 MyRepository.Project.SetCurrentProject(1)   
 Call MyRepository.Variable.AddVariable(NewVariable)
VB.NET

 Dim MyRepository As New Repository
 ...'Add code to connect to a Synthesis repository. 

 'Create a new variable. The following example creates a variable named "MyNewVariable". 
 Dim newVariable As New cVariable ("MyNewVariable")

 'Add the new variable to project #1. The variable will be visible in the Synthesis repository upon refresh. 
 MyRepository.Project.SetCurrentProject(1)   
 MyRepository.Variable.AddVariable(newVariable)