UnitInfo Class: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
Line 27: Line 27:
   ListOfUnits = MyRepository.GetAllUnits()
   ListOfUnits = MyRepository.GetAllUnits()
    
    
  {{APIComment|'Get the multiplier for the first unit in the list.
  {{APIComment|'Get the multiplier for the first unit in the list.}}
   Dim Mult As Double
   Dim Mult As Double
   Mult = ListOfUnits(0).Multiplier
   Mult = ListOfUnits(0).Multiplier

Revision as of 22:24, 27 May 2014


Used with Repository.GetAllUnits to describe a unit of measurement that has been defined in the current repository.

In Synthesis desktop applications, these units are shown in the Manage Units window.

Properties

  • ID (as integer) Gets numerical ID of the unit.
  • Name (as string) Gets the name of the unit.
  • Abbreviation (as string) Gets abbreviation of the unit.
  • Multiplier (as double) Gets the multiplier of the unit (i.e., the value to multiply by the Standard Base Unit (SBU), which determines how units are converted).

Usage Example

In this usage example, the multiplier for the first unit of measurement in a repository is retrieved.

 'Declare a new repository connection object. 
 Dim MyRepository As New Repository
 
 'Connect to the first project in the specified Synthesis repository. 
 Dim Success As Boolean = False
 Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
 MyRepository.SetCurrentProject(1)
 
 'Get the list of units for the current project for the connected repository. See GetAllUnits. 
 Dim ListOfUnits() As UnitInfo
 ListOfUnits = MyRepository.GetAllUnits()
 
 'Get the multiplier for the first unit in the list. 
 Dim Mult As Double
 Mult = ListOfUnits(0).Multiplier