Repository.Variable.GetVariable: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:
== Syntax ==
== Syntax ==
  '''.Variable.GetVariable'''(''ID'')
  '''.Variable.GetVariable'''(''ID'')
=== Parameters ===
=== Parameters ===
''ID''
''ID''
:Integer. The ID number of the variable to retrieve.
:Required. Integer. The ID number of the variable to retrieve.




== Example ==
== Example ==
The example assumes that a variable with ID# 1 exists in the repository.
The example assumes that a variable with ID #1 exists in the first project of a Synthesis repository.


  '''VBA'''
  '''VBA'''

Revision as of 23:33, 24 August 2015

APIWiki.png


Member of: SynthesisAPI10.Repository


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

.Variable.GetVariable(ID)

Parameters

ID

Required. Integer. The ID number of the variable to retrieve.


Example

The example assumes that a variable with ID #1 exists in the first project of a Synthesis repository.

VBA

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

  
 'Get variable #1 from project #1. 
 Dim AVariable As cVariable
 MyRepository.Project.SetCurrentProject(1)
 Set AVariable = MyRepository.Variable.GetVariable(1)

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

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

  
 'Get variable #1 from project #1. 
 Dim AVariable As cVariable
 MyRepository.Project.SetCurrentProject(1)
 AVariable = MyRepository.Variable.GetVariable(1)

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