Repository.Model.IsModelUsed: 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.IsModelUsed.Cmt}}
{{Template:API}}
Checks whether the model with the ID number that you specify is used by other items in the project. Returns a '''Boolean''' value; when true, indicates that the model is in use.  


== Syntax==
== Syntax ==
IsModelUsed({{APIPrefix|ByVal}} ID {{APIPrefix|As Integer}}) {{APIPrefix|As Boolean}}
''object''.'''Model.IsModelUsed(''ID'')'''


Parameters
where ''object'' is a variable that represents a Repository object.
:''ID'': The ID that will have its use checked.


== Usage Example ==
=== Parameters ===
{{APIComment|'Declare a new repository connection object.}}
{| {{APITable}}
  Dim MyRepository As New Repository
|-
 
|ID{{APIParam|Required}}||'''Integer'''. The ID number of the model to be checked.
{{APIComment|'Connect to the Synthesis repository.}}
|}
   Dim Success As Boolean = False
 
  Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
 
 
== Example ==
  {{APIComment|'Set a first available project as current.}}
This example assumes that a model with ID# 42 exists in the repository.
  MyRepository.Project.SetCurrentProject(0)
'''VBA|VB.NET'''<br>
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...'Add code to connect to a Synthesis repository.}}  
   
   
  {{APIComment|'Get the list of models in the current project.}}
  {{APIComment|'Check whether model #42 in project #1 is in use.}}
   Dim ListOfModels() As [[NameIdPair Class|NameIdPair]]
   MyRepository.Project.SetCurrentProject(1)   
  ListOfModels = MyRepository.Model.GetAllModelsInfo()
 
  {{APIComment|'Retrieve the model with ID &#061; 20.}}
  Dim AModel as cModel
  AModel = MyRepository.Model.GetModel(20)
    
    
{{APIComment|'Change the model's name.}}
   Dim CheckModel As Boolean
  AModel.Name = "New Name"
   CheckModel = MyRepository.Model.IsModelUsed(42)
 
{{APIComment|'Update the model in the repository.}}
   Dim SuccessUpdateModel As Boolean
   SuccessUpdateModel = MyRepository.Model.UpdateModel(20)
   
   
  {{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.Model.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}}

Revision as of 15:44, 14 July 2015

Member of: SynthesisAPI10Repository

APIWiki.png


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

Syntax

object.Model.IsModelUsed(ID)

where object is a variable that represents a Repository object.

Parameters

Name Description
IDborder="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse; text-align: left; cellborder"
Name Status Integer. The ID number of the model to be checked.


Example

This example assumes that a model with ID# 42 exists in the repository.

VBA|VB.NET
Dim MyRepository As New Repository ...'Add code to connect to a Synthesis repository. 'Check whether model #42 in project #1 is in use. MyRepository.Project.SetCurrentProject(1) Dim CheckModel As Boolean 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