IMsProblemScenarios.FindByKey

Syntax

FindByKey(ScenarioKey: Integer): IMsScenario;

Parameters

ScenarioKey. Scenario key.

Description

The FindByKey method searches for a scenario in the collection of modeling problem scenarios. Key of scenario, by which search is performed, is passed by the ScenarioKey parameter.

Example

Sub Main;

Var

MB: IMetabase;

MObj: IMetabaseObject;

KMSpace: IMsModelSpace;

Problem: IMsProblem;

ProbScen: IMsProblemScenarios;

Scen: IMsScenario;

Begin

MB := MetabaseClass.Active;

MObj := MB.ItemByIdNamespace("PROBLEM_1", MB.ItemById("KONT_MODEL").Key).Edit;

KMSpace := MB.ItemById("KONT_MODEL").Bind As IMsModelSpace;

Problem := MObj As IMsProblem;

ProbScen := Problem.Scenarios;

Scen := ProbScen.FindByKey((KMSpace.Scenarios.Item(0) As IMetabaseObject).Key);

If Scen = Null Then

ProbScen.AddScenario(KMSpace.Scenarios.Item(0));

End If;

MObj.Save;

End Sub Main;

After executing the example the first scenario of modeling container is searched in the collection of scenarios of the PROBLEM_1 modeling problem. In case of unsuccessful search the given scenario is added to the collection.

See also:

IMsProblemScenarios