Repository.Unit.GetAllUnits: 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.GetAllUnits.Cmt}}
{{Template:API}}
Returns a '''[[UnitInfo Class|UnitInfo]]''' object array that contains the name, ID number, abbreviation and multiplier of all predefined units in the current repository. In Synthesis desktop applications, these units are shown in the Manage Units window.  


== Syntax==
== Syntax ==
*GetAllUnits(){{APIPrefix|As}}[[UnitInfo Class|UnitInfo]]()
''object''.'''Project.GetAllUnits()'''


== Usage Example ==
where ''object'' is a variable that represents a Repository object.
<div style="margin-right: 150px;">
 
{{APIComment|'Declare a new repository connection object.}}
== Example ==
  Dim MyRepository As New Repository
'''VBA|VB.NET'''<br>
 
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|'Connect to the first project in the specified Synthesis repository.}}
  {{APIComment|...'Add code to connect to a Synthesis repository and set the first project in the repository as the current project.}} <br>
   Dim Success As Boolean = False
   {{APIPrefix|Dim}} ListOfUnits() {{APIPrefix|As}} UnitInfo
   Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
   ListOfUnits = MyRepository.Unit.GetAllUnits()<br>
  MyRepository.SetCurrentProject(1)
  {{APIComment|'Output example: Get the name and ID of the first available unit in the repository and display them in a message box.}}
 
  Dim UnitName {{APIPrefix|As}} String
  {{APIComment|'Get the list of units for the Current Project for the connected repository. See [[UnitInfo Class|UnitInfo]].}}
   Dim UnitID {{APIPrefix|As}} Integer<br>
   Dim ListOfUnits() As UnitInfo
  UnitName = ListofUnits(0).Name
   ListOfUnits = MyRepository.Unit.GetAllUnits()
   UnitID = ListofUnits(0).ID
</div>
  MsgBox ({{APIString|"The first available unit is: "}} & UnitName & {{APIString|", ID#"}} & UnitID)

Revision as of 20:23, 13 July 2015

Member of: SynthesisAPI10Repository

APIWiki.png


Returns a UnitInfo object array that contains the name, ID number, abbreviation and multiplier of all predefined units in the current repository. In Synthesis desktop applications, these units are shown in the Manage Units window.

Syntax

object.Project.GetAllUnits()

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 and set the first project in the repository as the current project.
Dim ListOfUnits() As UnitInfo ListOfUnits = MyRepository.Unit.GetAllUnits()
'Output example: Get the name and ID of the first available unit in the repository and display them in a message box. Dim UnitName As String Dim UnitID As Integer
UnitName = ListofUnits(0).Name UnitID = ListofUnits(0).ID MsgBox ("The first available unit is: " & UnitName & ", ID#" & UnitID)