Calculator
Question

Hello everyone!


I was just wondering what's the best way of creating a simple calcaulator on a empty screen.

Basically I have two inputs with an integer data type variable associated, I have a local variable for the result, but now I don't know what to do to create the logic for the calculator.


Can you help?


Thank you,


Tiago 

Hello Rui,


Thanks for your input. 

In the end I used a button group, I gave each button a value and used a switch to validate wich operation should run.


Tiago

mvp_badge
MVP

Hello Tiago,

Hope you're doing well.


There are several Calculator Forge components, maybe you could check them out and the logic behind them.


Reactive Web:

https://www.outsystems.com/forge/component-overview/8163/calculator-react

Traditional Web:

https://www.outsystems.com/forge/component-overview/6775/simple-calculator


Anyway, regarding to your description, you'll also need to have a third input (or at least something for the user to choose), which is the operator.

So you'll need 3 things, the first value, the operator and the second value.


According to that operator (plus, minus, obelus, times), you just need to apply it to those inputs and assign to the result local variable.


Kind regards,

Rui Barradas

Hello Rui,


Thanks for your input. 

In the end I used a button group, I gave each button a value and used a switch to validate wich operation should run.


Tiago

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.