• Well, I received no reply on the newspost. Finally found this forum. But I see someone else also asked about formulas and received not a single reply in months.

    Can someone tell me if formulas are implemented in WPForm. If they are, please give an example, particularly one that uses calculations for other fields (such as d=(a+b)/c where a, b, d, and d are other fields).

    If they aren't please at least respond that they aren't implemented.

    An answer would be appreciated.

    John-David Biggers (JD)

  • Hello.

    I have been asing questions about formulas, too, and no one even responds.

    I came up with a work-around.

    In the formula field, create a string in the following format:

    FunctionName|FieldToGetResult|UseField1:UseField2:UseField3

    Then, in the UpdatData section of the form, parse (using the "|" as the separator) the forumla into the function name, the field that gets the result, and the fields (as one string) to use for calculation.

    Then create a VBScript to modify the data, such as

    VBSCRIPT CODE

    function calcs5(params)
    z=split(params,":")
    calc5=(z(1) + z(2))/z(3)
    end function

    DELPHI CODE

    In the Delphi Program, you need to add an MSScript OCX control (the TAWScript is GREATE) I installed the TAWScript unit, so this basically is a wrapper around the MSScript OCX and creates a control call TAWScriptControl. I load the VB Code above intot he Code of the script control. Then I call it like below.

    In the UpdateData section code the following;

    (WPForm1.ObjectByName(FieldToGetResult) as TWPFGGraphic).ansiText
    =TAWScripControl1.CallFunction(calc5,[FieldsToGet]);

    Works perfect.

    Of course, it would be better if I knew one way or the other if formulas could actually be put in the formula field.

    The nice thing is you can store the VB Script into a multiline Text edit in the form, so each form can be independent of the program READING the form.

    John-David Biggers

    • Offizieller Beitrag

    Hi,

    The formula property of the graphic objects is a string field which can be used for formulas and anything else you need.

    I suggest to then build a loop over AllObjects[], AllObjectCount and use the script engine of your choice to calculate the formulas. WPTools bundle includes the WPEval code which can be used, too.

    Julian ZIersch