SPONSORS:






User Tag List

Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Nov 2004
    Location
    Downers Grove
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you add variables?

    Can anyone tell me how to add variables, as in actually adding them mathematically so they add to make a total and not just concatenate.
    Variable1 + Variable2. Can someone give me the exact syntax? Thanks in advance

    ------------------

  2. #2
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do you add variables?

    You want something like this:

    INTEGER i = 10
    INTEGER i2 = 14
    INTEGER iSum

    iSum = i + i2

    Hope this helps


    ------------------
    John W Green
    jwgreen@automationexpertise.com
    http://www.automationexpertise.com

  3. #3
    Junior Member
    Join Date
    Nov 2004
    Location
    Downers Grove
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do you add variables?

    That does help, but if I could add a kink to things perhaps you could help out even further. I am actually grabbing variables from a text box that changes dynamically according to what the customer orders. My goal is to grab each variable and add them at the end of the transaction to verify their total is the same as the variable I will grab from the receipt page. Lastly, the caption and tag for these text boxes is usually something like ?49.00[1] to signify $49.00. Do I need to do some sort of conversion? Any ideas? Thanks again!!!

    ------------------

  4. #4
    Guest

    Re: How do you add variables?

    You should probably use GetText().

    Of course if you GetText() returns the any money unit character like the $, then that will have to be stripped off. You could use the Right() function to strip one character off the left side.
    ------------------


    [This message has been edited by John Burross (edited 05-18-2001).]

  5. #5
    Junior Member
    Join Date
    Nov 2004
    Location
    Downers Grove
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do you add variables?

    So here is the situation I have. I am using GetText () to grab two transaction amounts from one page and also using GetText () to grab the total of the two from a receipt page. At the end of my code, I used Right() to cut off the $ signs. I want to verify that Total1 and Total2 equal GrandTotal. How do I get a successful results file that will have added these two amounts mathematically and not just concatenate Total1 and Total2.
    This is my code now:

    [ ] sTotal1 = (Right (sText, 5))
    [ ] sTotal2 = (Right (sText2, 5))
    [ ] sGrandTotal = (Right (sText3, 5))
    [ ]
    [ ] Verify (sTotal1 + sTotal2, sGrandTotal3)

    Right now the results are:
    Error: Verify value failed - got "49.0049.00", expected "98.00"

    Thanks again for any help!


    ------------------

  6. #6
    Guest

    Re: How do you add variables?

    You have to use Val(). If you don't, then you are simply concatenating strings, not adding numbers.


    ------------------


    [This message has been edited by John Burross (edited 05-21-2001).]

  7. #7
    Junior Member
    Join Date
    May 2001
    Location
    Portland, OR
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do you add variables?

    John is correct above, I'm only offering clarification.

    The Verify function is working properly. Since you are adding two strings, the result will not be the numerical one that you wish. Here is a modification to your example that should work:

    [ ] real rTotal1 = val(Right (sText, 5))
    [ ] real rTotal2 = val(Right (sText2, 5))
    [ ] real rGrandTotal = val(Right (sText3, 5))
    [ ]
    [ ] Verify (rTotal1 + rTotal2, rGrandTotal3)

    You must use real variables or you will loose your decimal places.

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:16 AM.

Copyright BetaSoft Inc.