Calculator Questions- How do I get the total to say "Free!" once it hits 0, or below?

Hi community!

I’m working on an XP that has a scene where a user can select cost shares. The price of the cost shares chosen is subtracted from the total of a membership. In the next scene, the total that the user would have to pay for their membership after their selected cost shares are applied is shown, saying “Congratulations! With your selected cost shares, your membership would only cost you:” and then the total is shown below.

I’ve got the calculator in an Excel doc, and it works well. I have the cost of membership ($15,000) in one cell (A2), the next cell holds the total from a shopping cart (B2). The final cell (C2) has the B2 (cost shares from shopping cart) subtracted from the membership (A2)

HOWEVER! I’m trying to come up with a formula that would keep the total the user would have to pay (C2) from showing 0 and below (we don’t want it to say that the user would have to pay -$200, for example). Once it hits zero (or below), I would like it to say “Free!”

How would I implement this? Would I come up with a formula within Excel, and what would it look like? Or would I need to create a custom script within Intuiface to do this? Help! Formulas can melt my brain at times. :open_mouth:

Thanks in advance!
Megan

Update: @Promultis helped me by suggesting I put an action on the text that I had bound to the Calculator that showed the total. In the trigger, I put a timer for .01 sec, with a condition saying that if it equaled or was less than 0, to set text to “Free!” Works like a charm. Attached is a screenshot.

2 Likes

This could be done a variety of other ways as well. For instance, using the Comparator Interface Asset.

But for situations like this, I personally tend to use a binding converter instead of an action. I would make a text item called Free and bind the visibility of it to the calculator. Then use a custom script converter that may look something like this:
IF (INPUT =< 0)
true;
Else
false;

That way the Free is automatically shown with no actions required. You could then bind your regular number’s visibility to the Free text, and use the NOT converter. This means the number is always the opposite of the Free visibility. So when Free is shown, then number is not. When Free is not shown, the number is. Of course you could also use an ‘is shown’ action on Free text to hide the regular number too.

Just some other ideas to spark some creativity. @Seb may need to double check my custom converter up there to make sure the syntax is right.

3 Likes

That sounds good Alex :wink:

@AlexB

Huh! I never would have thought of that!

I love seeing all the different ways that people have to solve a problem. :slight_smile:

1 Like