IMsDatePeriod.Assign

Syntax

Assign(Preiod: IMsDatePeriod);

Parameters

Preiod. Copied period.

Description

The Assign method copies parameters of the specified period to the current period.

Comments

This method enables the entire copy of period parameters including internal properties.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a forecasting problem with the PROBLEM_COPIED identifier.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    MsKey: Integer;
    CrInfo: IMetabaseObjectCreateInfo;
    ProblemCopied, ProblemCopy: IMsProblem;
    i: Integer;
    CalcSettCopied, CalcSettCopy: IMsProblemCalculationSettings;
    PeriodCopied, PeriodCopy: IMsModelPeriod;
    OutputPeriodCopied, OutputPeriodCopy: IMsDatePeriod;
    ProblemCalc: IMsProblemCalculation;
Begin
    mb := metabaseClass.Active;
    // Get modelling container key
    MsKey := mb.GetObjectKeyById("MS");
    // Get copied problem
    ProblemCopied := mb.ItemByIdNamespace("PROBLEM_COPIED", MsKey).Edit As IMsProblem;
    // Create object for a copy problem
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MSPROBLEM;
    CrInfo.Id := MB.GenerateId("PROBLEM_COPY", MsKey);
    CrInfo.Name := "Modeling problem (copy)";
    CrInfo.Parent := ProblemCopied.MetabaseObject.Parent;
    ProblemCopy := MB.CreateObject(CrInfo).Edit As IMsProblem;
    // Copy metamodel  
    ProblemCopy.MetaModel := ProblemCopied.MetaModel;
    // Copy problem parameters
    ProblemCopy.Details := ProblemCopied.Details;
    // Copy scenario
    For i := 0 To ProblemCopied.Scenarios.Count - 1 Do
        ProblemCopy.Scenarios.AddScenario(ProblemCopied.Scenarios.Item(i));
    End For;
    // Copy data loading period parameters
    CalcSettCopied := ProblemCopied.CreateCalculationSettings;
    OutputPeriodCopied := CalcSettCopied.OutputPeriod As IMsDatePeriod;
    CalcSettCopy := ProblemCopy.CreateCalculationSettings;
    OutputPeriodCopy := CalcSettCopy.OutputPeriod As IMsDatePeriod;
    OutputPeriodCopy.Assign(OutputPeriodCopied);
    // Copy problem calculation periods
    PeriodCopied := CalcSettCopied.Period;
    PeriodCopy := CalcSettCopy.Period;
    PeriodCopy.Assign(PeriodCopied);
    // Save copy
    (ProblemCopy As IMetabaseObject).Save;
    // Calculate copy problem
    ProblemCalc := ProblemCopy.Calculate(CalcSettCopy);
    ProblemCalc.Run;
End Sub UserProc;

After executing the example the PROBLEM_COPIED problem is copied. The created copy will be calculated.

See also:

IMsDatePeriod