Trying to build a somewhat complicated calculator. Right now I'm just building the interface, and creating the variables that will be holding values which will be used in the logic of the final "calculate" button.


I noticed that all buttons must be assigned values. Do I also have to create a separate variable that will hold a specific value when the user clicks a specific button, or can I just rely on the value of the button itself?


Note that the calculate button will be on the last screen, so I will be referring to Button values from previous screens. Is this possible or should I create variables for each button to store their values at a higher level?

You can create one action with an input parameter. Now use this same action for on click event of all buttons and pass the button's respactive value.

Because you want to use these values on different screen so you can keep all the values/ complete formula (which you have created in your calculator) in session/ client variable (based on type of application you are using).

Upon calculate button click get values/ formula from session/ client variable and do your calculation. 

Nikhil Gaur wrote:

You can create one action with an input parameter. Now use this same action for on click event of all buttons and pass the button's respactive value.

Because you want to use these values on different screen so you can keep all the values/ complete formula (which you have created in your calculator) in session/ client variable (based on type of application you are using).

Upon calculate button click get values/ formula from session/ client variable and do your calculation. 

How do I pass a value from an input parameter in a certain screen to a higher level? (for example to the next screen, or to a client variable?)


You use events to return values back to the parent.  Check out this training https://www.outsystems.com/learn/courses/121/blocks-and-events/

Hi Akis,

Nikhil is the way to go. You can check this component that took that approach to build a simple calculator.

Regards,

Marcelo

Akis M wrote:

Nikhil Gaur wrote:

You can create one action with an input parameter. Now use this same action for on click event of all buttons and pass the button's respactive value.

Because you want to use these values on different screen so you can keep all the values/ complete formula (which you have created in your calculator) in session/ client variable (based on type of application you are using).

Upon calculate button click get values/ formula from session/ client variable and do your calculation. 

How do I pass a value from an input parameter in a certain screen to a higher level? (for example to the next screen, or to a client variable?)



Hi Akis,

As Marcelo as shared, please check this simple canculator forge if it has implemented the calculator same way then it will be very simple for you to follow same approach.

Otherwise as Rebacca has shared you can use block events to send data from block to its parent.

Hi all, and thanks for your input. I looked both into the events tutorial, and the calculator provided above. I am however still confused unfortunately, as I'm very new to this.

I am attaching below a simplified sample of what I'm trying to do (which has errors). If someone could have a look and maybe edit a couple of elements (without changing UI etc) so I can look at it and apply it to my real application, that would be great and probably the best way to understand.

I am aware that all of that could be done in a single screen, but I'm using multiple screens and buttons since in my calculator all that will be necessary.

Thank you.

I'm surprised I'm having a hard time figuring out how to use a variable across different screens. I feel like this should be a very simple implementation.


Could someone provide an example module where user enters a value in screen 1, then another value in screen 2 and so on, then calls those values and uses them in a calculation in another screen? Every time I create a variable it's stuck in that screen and I can't use it in any other screen, whether that's an input or a local variable. I'm just looking for a variable that has global scope and can be used in all screens. Or a simple method that does that. I tried playing around with events and blocks but even after watching the tutorials it's confusing.

Solution

Hi! 

Are you working in a  Mobile app or a web one? 

If you are in a mobile are in the "data" tab

You can create your variables there and , in the screen use them to save the values entered. 

If you are working in Web app you can use "Session Variables" in the same way

Regards 

Graça

Solution

Hi Akis,

First of all why it needs to be different screens? Because what you are describing you should do it with something like a wizard and not multiple screens.

To pass variables for one screen o other there are multiple ways: 

  • use and input and when you call the next screen pass it
  • use session
  • use database

For events check this post which have an example.

Regards,

Marcelo