Repository.Project.GetCurrentProject: 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|9|Repository}}
{{Template:Repository.GetCurrentProject.Cmt}}
{{Template:API}}
Returns a '''[[NameIdPair Class|NameIDPair]] object that contains the name and ID number of the project you are currently connected to.


== Syntax==
== Syntax ==
''object''.'''Project.GetCurrentProject()'''


*GetCurrentProject(){{APIPrefix|As}}[[NameIdPair Class|NameIdPair]]
where ''object'' is a variable that represents a Repository object.


== Usage Example ==
== Example ==
In this usage example, a project is opened in a Synthesis repository, and the ID of the project is retrieved.
'''VBA|VB.NET'''<br>
{{APIComment|'Declare a new repository connection object. See [[Repository Class|Repository]].}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  Dim MyRepository As New Repository
  {{APIComment|...'Add code to connect to a Synthesis repository.}} <br>
 
  {{APIComment|'Set the first available project in the repository as the current project.}}
  {{APIComment|'Connect to a Synthesis repository.}}
  MyRepository.Project.SetCurrentProject(1)<br>
  Dim Success As Boolean = False
  {{APIComment|'Output example: Get the name and ID of the current project and display it in a message box.}}
  Success = MyRepository.ConnectToRepository("C:\Users\Name\Documents\ReliaSoft\Files\repository.rsr9")
  Dim ProjectName {{APIPrefix|As}} String
 
  Dim ProjectID {{APIPrefix|As}} Integer<br>
  {{APIComment|'Get a list of the names/IDs of projects in the connected repository.}}
  ProjectName = MyRepository.Project.GetCurrentProject().Name
  Dim ListOfProjects() As NameIdPair
  ProjectID = MyRepository.Project.GetCurrentProject().ID
  ListOfProjects = MyRepository.Project.GetAllProjects()
  MsgBox ({{APIString|"You are currently connected to: "}} & ProjectName & {{APIString|", ID#"}} & ProjectID)
 
  {{APIComment|'Open the first project in the list.}}
  MyRepository.Project.SetCurrentProject(ListOfProjects(0).ID)
 
{{APIComment|'Get the ID of the opened project.}}
  Dim ID As Integer
  ID = MyRepository.Project.GetCurrentProject()
 
{{APIComment|'Disconnect from the repository.}}
  MyRepository.DisconnectFromRepository()

Revision as of 18:49, 13 July 2015

Member of: SynthesisAPI9Repository

APIWiki.png


Returns a NameIDPair object that contains the name and ID number of the project you are currently connected to.

Syntax

object.Project.GetCurrentProject()

where object is a variable that represents a Repository object.

Example

VBA|VB.NET
Dim MyRepository As New Repository ...'Add code to connect to a Synthesis repository.
'Set the first available project in the repository as the current project. MyRepository.Project.SetCurrentProject(1)
'Output example: Get the name and ID of the current project and display it in a message box. Dim ProjectName As String Dim ProjectID As Integer
ProjectName = MyRepository.Project.GetCurrentProject().Name ProjectID = MyRepository.Project.GetCurrentProject().ID MsgBox ("You are currently connected to: " & ProjectName & ", ID#" & ProjectID)