FlexPro Forum – Discuss Your Topic!

Datensatz – Maximum

Home > Community > Automation and VBA > Datensatz – Maximum

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12396

    In meinem C++-Programm habe ich ein Datensatz-Objekt. Wie kann ich davon dan Maximum berechnen? Ich denke es soll über die FPScript Funktion Maximum() gehen, aber wie das genau geht weiss ich nicht.

    IDataSetPtr fpDSet;			
    fpDSet = (IDataSetPtr)fpDB->GetObject((dataset_name), fpObjectTypeDataSet)
    
    double max;
    max = fpDSet->??
    

    Danke für die Hilfe

    #8079

    In meinem C++-Programm habe ich ein Datensatz-Objekt. Wie kann ich davon dan Maximum berechnen? Ich denke es soll über die FPScript Funktion Maximum() gehen, aber wie das genau geht weiss ich nicht.

    IDataSetPtr fpDSet;			
    fpDSet = (IDataSetPtr)fpDB->GetObject((dataset_name), fpObjectTypeDataSet)
    
    double max;
    max = fpDSet->??
    

    Danke für die Hilfe

    #8624
    Bernhard KantzBernhard Kantz
    Participant

    Create a FPScript formula in your database to calcuate the maximum. Alternatively you can do this with Automation. You get the result of the formula with the value-property of the formula object.

    VBA-Example: Maximum of the signal ‘Signal’

    
    
    


    Dim oFml As Formula
    Dim value As Double
    Set oFml = ActiveDatabase.RootFolder.Add(“Maximum”, fpObjectTypeFormula)
    With oFml
    .Formula = “Maximum(Signal)”
    .Update
    value = .value
    End With

    [/code]

    support@weisang.com

    #8625

    Ich kenne zur Laufzeit aber den Datensatz-Name nicht. Kann ich diesen als Variable übergeben

    sowas wie: .Formula = “Maximum(%oDst.Name)”

    #8626
    Bernhard KantzBernhard Kantz
    Participant

    You could use String operators to create your FPScript code:

    VBA:

    
    .Formula = "Maximum(" & oDst.Name & ")"
    

    support@weisang.com

    #8627

    Ah ja ok.. thanks

    so sieht der C/C++ Code aus, für die interssierten

    		// Maximun-Formula
    		fpFrml_temp = (IFormulaPtr)fpDSet->GetParentFolder()->Add("maxFormula", fpObjectTypeFormula, fpNameClashHandlingOverwrite, _bstr_t(), _bstr_t());
    		
    		// Maximum-Formula-String zusammenstellen
    		char strFormulaMax[MAX_PATH];	
    		strcpy_s(strFormulaMax, "Maximum('");
    		strcat(strFormulaMax, (char *)fpDSet->GetName()); // _bstr_t in char * konvertieren
    		strcat(strFormulaMax, "')");
    
    		fpFrml_temp->PutFormula(strFormulaMax);
    		fpFrml_temp->Update();
    		max = fpFrml_temp->GetValue(fpDataComponentAll, column, 1); 
    		fpFrml_temp->Delete(); // nicht mehr brauchbar
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.