Forum Discussion

gdave's avatar
gdave
Regular Contributor
7 years ago

Code Expression

Hi all I've used the below code expression in my test: "aqConvert.StrToInt(ProjectSuite.Variables.XX) * aqConvert.StrToInt(ProjectSuite.Variables.YY)"   The above code is suppose to multiply ...
  • AlexKaras's avatar
    AlexKaras
    7 years ago

    Hi,

     

    > now I am stuck with the rounding issue.

    Well, I still assume that you are dealing with money (i.e. currency data type)...

    There is no direct support for currency in DelphiScript. Below are quick ideas that came first to my head:

    -- Use already mentioned Round() function that seems to implement bank rounding rules and use it to create your own code to handle currency. As Round() rounds to integers, you will need to shift calculation base to the right as required, do calculations and than return back. E.g.:

    for the initial 3.257 * 354.66 = 1155.13 you need something like this (100 multiplier/divider is used because we are rounding to two digits after comma):

    (3.257 * 354.66) * 100 = 115512.762 ==> Round(115512.762) = 115513 ==> 115513 / 100 = 1155.13

     

    -- Ask your developers (or do it yourself) to create a DLL that conforms to TestComplete's requirements (see help for the DLL object) and implements currency calculations. Then call functions provided by this DLL;

    -- If .Net is installed on the computers where TestComplete tests are executed, then investigate if .Net provides currency calculation routines that can be called from TestComplete via the dotNET object and use them (https://stackoverflow.com/questions/2215601/money-data-type-for-net ?);

    -- Create a Script Extension in TestComplete using some already existing VBScript or JScript code/library and use this Script Extension from your code. (https://frontstuff.io/how-to-handle-monetary-values-in-javascript, http://openexchangerates.github.io/accounting.js/)