Can eggplant extract a number and return it to program?

Hi,

I've searched, but could not find clarification. Can someone help with this ..

Can eggplant extract what is the numeric value from a position captured?
For e.g. If we have excel sheet and it has a value in particular cell, can it capture what is the value in the cell and do some comparison to value in any file or return it as a numeric value so, some calculation can be done on the number returned in the script that is being recorded ?

Thanks,
Vasavi Kaza

Comments

  • Hello Vasavi Kaza,

    You should be able to copy the contents of the cell (make sure you are copying the contents, and not the cell itself) using
    ControlKey, "c"
    
    for windows and
    CommandKey, "c"
    
    for Mac. Then you can bring the copied contents of the cell into your script using the
    RemoteClipboard()
    
    function and manipulate it from there.
    You can also cut the text out of the cell instead of copying it, bring it into your script to manipulate it, and then put the new value back into the same cell if you desire.

    Once the value is in your script (you can put it in a variable), then you can compare the value to other values in an external file and/or perform various calculations with that value.

    Your code might look something like this:
    //Navigate to the cell and click inside of it
    ControlKey, "c" -- copy the text (not the cell)
    put RemoteClipboard() into CopiedText -- store the copied value in a variable
    put item 1 of line 1 of file "/path/to/somefile.txt" into FileValue -- get the desired value out of an external file and store it in a variable for manipulation
    Put CopiedText + FileValue into AddedValues -- add the values together or perform some other calculation
    // do something with the outcome of the calculation (AddedValues)
    

    -Elizabeth
Sign In or Register to comment.