Repository.Variable.GetVariable: 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.GetVariable.Cmt}}
{{Template:API}}
Gets the variable with the designated ID number and returns it as a '''[[CVariable Class|cVariable]]''' object. Returns nothing if the variable does not exist or is not in the current project.


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


Parameters
where ''object'' is a variable that represents a Repository object.


Enter the Variable ID to get desired Variable.
=== Parameters ===
{| {{APITable}}
|-
|ID{{APIParam|Required}}||'''Integer'''. The ID number of the variable to retrieve.
|}


== Usage Example ==
 
  {{APIComment|'Declare a new repository connection object.}}
== Example ==
   Dim MyRepository As New Repository
The example assumes that a variable with ID# 1 exists in the repository.
    
 
  {{APIComment|'Connect to the Synthesis repository.}}
'''VBA'''
   Dim Success As Boolean = False
   Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
    
  {{APIComment|...'Add code to connect to a Synthesis repository.}}
  {{APIComment|'Set a first available project as current.}}
 
  MyRepository.Project.SetCurrentProject(0)
{{APIComment|'Get variable #1 from project#1.}}
   {{APIPrefix|Dim}} AVariable {{APIPrefix|As}} cVariable
  MyRepository.Project.SetCurrentProject(1)
   {{APIPrefix|Set}} AVariable = MyRepository.Variable.GetVariable(1)
  {{APIComment|'Output sample:}}
  {{APIPrefix|Dim}} VariableName {{APIPrefix|As}} String
   {{APIPrefix|Dim}} VariableID {{APIPrefix|As}} Integer
  VariableName = AVariable.Name
   VariableID = AVariable.ID
  MsgBox ({{APIString|"You got "}} & VariableName & {{APIString|", ID#"}} & VariableID)
 
'''VB.NET'''
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...'Add code to connect to a Synthesis repository.}}
    
    
  {{APIComment|'Get a Variable.}}
  {{APIComment|'Get variable #1 from project#1.}}
   Dim GetVariable() as cVariable
   {{APIPrefix|Dim}} AVariable {{APIPrefix|As}} cVariable
   GetVariable MyRepository.Variable.GetVariable(1)
  MyRepository.Project.SetCurrentProject(1)
   AVariable = MyRepository.Variable.GetVariable(1)
{{APIComment|'Output sample:}}
  {{APIPrefix|Dim}} VariableName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} VariableID {{APIPrefix|As}} Integer
  VariableName = AVariable.Name
  VariableID = AVariable.ID
  MsgBox ({{APIString|"You got "}} & VariableName & {{APIString|", ID#"}} & VariableID)

Revision as of 23:25, 14 July 2015

Member of: SynthesisAPI10Repository

APIWiki.png


Gets the variable with the designated ID number and returns it as a cVariable object. Returns nothing if the variable does not exist or is not in the current project.

Syntax

object.Variable.GetVariable()

where object is a variable that represents a Repository object.

Parameters

Name Description
IDborder="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse; text-align: left; cellborder"
Name Status Integer. The ID number of the variable to retrieve.


Example

The example assumes that a variable with ID# 1 exists in the repository.

VBA

 Dim MyRepository As New Repository
 ...'Add code to connect to a Synthesis repository. 
  
 'Get variable #1 from project#1. 
 Dim AVariable As cVariable
 MyRepository.Project.SetCurrentProject(1)
 Set AVariable = MyRepository.Variable.GetVariable(1)

 'Output sample: 
 Dim VariableName As String
 Dim VariableID As Integer
 VariableName = AVariable.Name
 VariableID = AVariable.ID
 MsgBox ("You got " & VariableName & ", ID#" & VariableID)
VB.NET

 Dim MyRepository As New Repository
 ...'Add code to connect to a Synthesis repository. 
  
 'Get variable #1 from project#1. 
 Dim AVariable As cVariable
 MyRepository.Project.SetCurrentProject(1)
 AVariable = MyRepository.Variable.GetVariable(1)

 'Output sample: 
 Dim VariableName As String
 Dim VariableID As Integer
 VariableName = AVariable.Name
 VariableID = AVariable.ID
 MsgBox ("You got " & VariableName & ", ID#" & VariableID)