Repository.Model.IsModelUsed: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}
{{Template:Repository.IsModelUsed.Cmt}}


== Syntax==
IsModelUsed({{APIPrefix|ByVal}} ID {{APIPrefix|As Integer}}) {{APIPrefix|As Boolean}}


Parameters
<onlyinclude>Checks whether the model is used by other items in the project. Returns a '''Boolean''' value; when true, indicates that the model is in use.</onlyinclude>
:''ID'': The ID that will have its use checked.


== Usage Example ==
== Syntax ==
  {{APIComment|'Declare a new repository connection object.}}
  '''.Model.IsModelUsed'''(''ID'')
  Dim MyRepository As New Repository
 
 
=== Parameters ===
{{APIComment|'Connect to the Synthesis repository.}}
''ID''
  Dim Success As Boolean = False
:Required. Integer. The ID number of the model to be checked.
  Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
 
 
 
  {{APIComment|'Get the list of models in the connected repository.}}
== Example ==
  Dim ListOfModels() As [[NameIdPair Class|NameIdPair]]
This example assumes that a model with ID #42 exists in the first available project of a Synthesis repository.
  ListOfModels = MyRepository.GetAllModelsInfo()
'''VBA|VB.NET'''
 
{{APIComment|'Retrieve the model with ID &#061; 20.}}
  {{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
  Dim AModel as cModel
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  AModel = MyRepository.GetModel(20)
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
 
{{APIComment|'Change the model's name.}}
  AModel.Name = "New Name"
    
    
  {{APIComment|'Update the model in the repository.}}
  {{APIComment|'Check whether model #42 from project #1 is in use.}}
  Dim SuccessUpdateModel As Boolean
  {{APIPrefix|Dim}} CheckModel {{APIPrefix|As Boolean}}
  SuccessUpdateModel = MyRepository.UpdateModel(20)
  MyRepository.Project.SetCurrentProject(1) 
  CheckModel = MyRepository.Model.IsModelUsed(42)
   
   
  {{APIComment|'Check to see if Model 20 is being used.}}
  {{APIComment|'Output sample.}}
  Dim SucessIsModelUsed As Boolean
  {{APIPrefix|If}} CheckModel = {{APIPrefix|True Then}}
  SucessIsModelUsed = MyRepository.IsModelUsed (20)
    MsgBox ({{APIString|"The model is in use."}})
   
  {{APIPrefix|Else}}
{{APIComment|'Disconnect from the repository.}}
    MsgBox ({{APIString|"The model is not in use."}})
  MyRepository.DisconnectFromRepository
  {{APIPrefix|End If}}

Latest revision as of 18:57, 8 April 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Checks whether the model is used by other items in the project. Returns a Boolean value; when true, indicates that the model is in use.

Syntax

.Model.IsModelUsed(ID)

Parameters

ID

Required. Integer. The ID number of the model to be checked.


Example

This example assumes that a model with ID #42 exists in the first available project of a Synthesis repository.

VBA|VB.NET

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
  
 'Check whether model #42 from project #1 is in use. 
  Dim CheckModel As Boolean
  MyRepository.Project.SetCurrentProject(1)  
  CheckModel = MyRepository.Model.IsModelUsed(42)

 'Output sample. 
  If CheckModel = True Then
    MsgBox ("The model is in use.")
  Else
    MsgBox ("The model is not in use.")
  End If