Difference between revisions of "Repository.Variable.AddVariable"

From ReliaWiki
Jump to navigation Jump to search
Line 1: Line 1:
{{Template:APIBreadcrumb|10|[[Repository Class|Repository]]}}
+
<noinclude>{{Template:API}}{{Template:APIBreadcrumb|10|.[[Repository Class|Repository]]}}</noinclude>
{{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. 
 
  
 +
 +
Saves a new [[CVariable Class|cVariable]] object to the current project. Returns a '''Boolean''' value; when true, indicates a successful save. 
 +
<noinclude>
 +
If a variable with the same name already exists in the current project, the application will automatically increment the name. For example, if "Var1" already exists, the new variable might be renamed to "Var2," "Var3," etc.
 
== Syntax ==
 
== Syntax ==
''object''.'''Variable.AddVariable(''var'')'''
+
'''.Variable.AddVariable'''(''var'')
 
 
where ''object'' is a variable that represents a Repository object.
 
  
 
=== Parameters ===
 
=== Parameters ===
{| {{APITable}}
+
''var''
|-
+
:The [[CVariable Class|cVariable]] object to be added. (Required)
|var{{APIParam|Required}}||The [[CVariable Class|cVariable]] object to be added.
 
|}
 
  
  
 
== Example ==
 
== Example ==
'''VBA'''
+
This example creates a new variable resource, and then saves it in the first available project in a Synthesis repository.
 +
'''VBA'''
 +
 +
{{APIComment|'Add code to connect to a Synthesis repository.}}
 +
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
 +
  {{APIComment|...}}
 
   
 
   
  {{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."}}
 
  {{APIComment|'Create a new variable. The following example creates a variable named "MyNewVariable."}}
Line 31: Line 32:
 
  '''VB.NET'''
 
  '''VB.NET'''
 
   
 
   
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
+
{{APIComment|'Add code to connect to a Synthesis repository.}}
{{APIComment|...'Add code to connect to a Synthesis repository.}}
+
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
 +
  {{APIComment|...}}
 +
 
   
 
   
 
  {{APIComment|'Create a new variable. The following example creates a variable named "MyNewVariable."}}
 
  {{APIComment|'Create a new variable. The following example creates a variable named "MyNewVariable."}}
Line 40: Line 43:
 
   MyRepository.Project.SetCurrentProject(1)   
 
   MyRepository.Project.SetCurrentProject(1)   
 
   MyRepository.Variable.AddVariable(newVariable)
 
   MyRepository.Variable.AddVariable(newVariable)
 +
</noinclude>

Revision as of 18:52, 20 July 2015

APIWiki.png


Member of: SynthesisAPI10.Repository


Saves a new cVariable object to the current project. Returns a Boolean value; when true, indicates a successful save.

If a variable with the same name already exists in the current project, the application will automatically increment the name. For example, if "Var1" already exists, the new variable might be renamed to "Var2," "Var3," etc.

Syntax

.Variable.AddVariable(var)

Parameters

var

The cVariable object to be added. (Required)


Example

This example creates a new variable resource, and then saves it in the first available project in a Synthesis repository.

VBA

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New 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

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New 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)