Repository.Variable.GetVariable: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:




<onlyinclude>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.</onlyinclude>   
<onlyinclude>Returns a '''[[CVariable Class|cVariable]]''' object that represents a given variable resource in the current project. Returns nothing if the variable does not exist or is not in the current project.</onlyinclude>   


== Syntax ==
== Syntax ==
Line 17: Line 17:
  '''VBA'''
  '''VBA'''
   
   
  {{APIComment|'Add code to connect to a Synthesis repository.}}
  {{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
   
 
  {{APIComment|'Get variable #1 from project #1.}}
  {{APIComment|'Get variable #1 from project #1.}}
  {{APIPrefix|Dim}} AVariable {{APIPrefix|As}} cVariable
  {{APIPrefix|Dim}} AVariable {{APIPrefix|As}} cVariable
  MyRepository.Project.SetCurrentProject(1)
  MyRepository.Project.SetCurrentProject(1)
  {{APIPrefix|Set}} AVariable = MyRepository.Variable.GetVariable(1)
  {{APIPrefix|Set}} AVariable = MyRepository.Variable.GetVariable(1)
   
   
  {{APIComment|'Output sample: Display the name and ID of the variable.}}
  {{APIComment|'Output sample: Display the name and ID of the variable.}}
  {{APIPrefix|Dim}} VariableName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} VariableName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} VariableID {{APIPrefix|As}} Integer
  {{APIPrefix|Dim}} VariableID {{APIPrefix|As}} Integer
  VariableName = AVariable.Name
  VariableName = AVariable.Name
  VariableID = AVariable.ID
  VariableID = AVariable.ID
  MsgBox ({{APIString|"You got "}} & VariableName & {{APIString|", ID#"}} & VariableID)
  MsgBox ({{APIString|"You got "}} & VariableName & {{APIString|", ID#"}} & VariableID)


  '''VB.NET'''
  '''VB.NET'''
   
   
  {{APIComment|'Add code to connect to a Synthesis repository.}}
  {{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
   
 
  {{APIComment|'Get variable #1 from project #1.}}
  {{APIComment|'Get variable #1 from project #1.}}
  {{APIPrefix|Dim}} AVariable {{APIPrefix|As}} cVariable
  {{APIPrefix|Dim}} AVariable {{APIPrefix|As}} cVariable
  MyRepository.Project.SetCurrentProject(1)
  MyRepository.Project.SetCurrentProject(1)
  AVariable = MyRepository.Variable.GetVariable(1)
  AVariable = MyRepository.Variable.GetVariable(1)
   
   
  {{APIComment|'Output sample: Display the name and ID of the variable.}}
  {{APIComment|'Output sample: Display the name and ID of the variable.}}
  {{APIPrefix|Dim}} VariableName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} VariableName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} VariableID {{APIPrefix|As}} Integer
  {{APIPrefix|Dim}} VariableID {{APIPrefix|As}} Integer
  VariableName = AVariable.Name
  VariableName = AVariable.Name
  VariableID = AVariable.ID
  VariableID = AVariable.ID
  MsgBox ({{APIString|"You got "}} & VariableName & {{APIString|", ID#"}} & VariableID)
  MsgBox ({{APIString|"You got "}} & VariableName & {{APIString|", ID#"}} & VariableID)

Latest revision as of 18:55, 9 June 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Returns a cVariable object that represents a given variable resource in the current project. 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

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
   
 '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

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
   
 '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)