IMsProblemCalculationSettings.ValueFlag

Syntax

ValueFlag: Integer;

Description

The ValueFlag property determines value of the flag that is used to select changed values.

Comments

By default, the value specified in IMsProblem.ValueFlag is put as a property value. The saving algorithm determined in IMsProblem.ValueFlag is used in this case.

If a proper value that is greater than 0 is set for the ValueFlag current property, the data is saved, for which the sent flag of changed values is set. The available value of the property is in the range [0; 255].

Flag value is available in the IMsProblemCalculationCallback.OnBeforeSaveData and IMsProblemCalculationCallback.OnSaveData events.

Example

Executing the example requires a time series database with the TSDB identifier. The modeling container that is a child object of the database has a modeling problem with the TSDB_PROBLEM identifier.

Add links to the Cubes, Matrix, Metabase, Ms system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Rub: IRubricator;
    Problem: IMsProblem;
    Calculation: IMsProblemCalculation;
    CalcSettings: IMsProblemCalculationSettings;
Begin
    Mb := MetabaseClass.Active;
    Rub := MB.ItemById(
"TSDB").Bind As IRubricator;
    
// Get problem in TSDB modeling container
    Problem := Mb.ItemByIdNamespace("TSDB_PROBLEM", Rub.ModelSpace.Key).Edit As IMsProblem;
    
// Flag that will be assigned to changed data
    // Set problem calculation parameters
    CalcSettings := Problem.CreateCalculationSettings;
    CalcSettings.FactIncluded := 
True;
    CalcSettings.BreakOnError := 
True;
    // Execute problem with ValueFlag=2
    //...
    //Specify in CalcSettings the first set of parameters for calculation
    //...
    CalcSettings.ValueFlag := 2;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.Callback := 
New MCallback.Create;
    Calculation.Run;
    // Execute problem with ValueFlag=3
    //...
    //Specify in CalcSettings the second set of parameters for calculation
    //...
    CalcSettings.ValueFlag := 3;
    Calculation := Problem.Calculate(CalcSettings);
    Calculation.Callback := 
New MCallback.Create;
    Calculation.Run;
End Sub UserProc;

Public Class MCallback: ProblemCalculationCallback
    
Public Sub OnBeforeSaveData(Stub: IVariableStub; Matrix: IMatrix; Var ValueFlag: Integer; Var Cancel: Boolean);
    
Begin
        Debug.WriteLine(ValueFlag);
        
Select Case ValueFlag
            
Case 2:
                
//...
                //Process data that must be saved if ValueFlag = 2
                //...
            Case 3:
                
//...
                //Process data that must be saved if ValueFlag = 3
                //...
        End Select;
    
End Sub OnBeforeSaveData;

    
Public Sub OnSaveData(Stub: IVariableStub; Matrix: IMatrix; ValueFlag: Integer; AuditRecordKey: Variant);
    
Var
        Iter: IMatrixIterator;
        RecordCount: Integer;
    
Begin
        Iter := Matrix.CreateIterator;
        Iter.Move(IteratorDirection.First);
        
While Iter.Valid Do
            
If Iter.ValueFlag = ValueFlag Then
                RecordCount := RecordCount + 
1;
            
End If;
            Iter.Move(IteratorDirection.Next);
        
End While;
        Debug.WriteLine(
"Data is saved on ValueFlag: " + ValueFlag.ToString + #13 + #10 +
            
"Number of saved values: " + RecordCount.ToString + #13 + #10 +
            
"Key of record in access protocol: " + AuditRecordKey);
    
End Sub OnSaveData;
End Class MCallback;

After executing the example the modeling problem is calculated with two different sets of parameters. Different flags of changed values will be set for calculated data. Additional data processing can be executed in the OnBeforeSaveData event by flag. After the data is saved, the development environment console displays information about the number of saved values and key of the record in access protocol that corresponds to data saving.

See also:

IMsProblemCalculationSettings