Compute scores based on user input (e.g. BMI score)

Here's how you can use PhraseExpander to compute the BMI score based on user input.

The Calculate BMI form

1

Create two Manual Input fields, one for the height, one for the weight by clicking on Macro → Manual Input

Manual Input definition window

After entering the two manual inputs, PhraseExpander will generate code similar to this:

{#input -[desc=Weight (in Kg)]#}{#input -[desc=Height in meters]#}<br>
	
2

Wrap each manual input into a variable, so the value can be used to compute the score. Select the Manual Input text and click on Macro → Set variable

Store a manual input into a variable

And assign a variable name. Here's the associated code.

{#varSet {#input -[desc=Weight (in Kg)]#} -[name=weight][hide=1]#}{#varSet {#input -[desc=Height in meters]#} -[name=height][hide=1]#}<br>
	
3

Now that we have the information we need in the weight and height variables, we compute the score by using the calc macro, by clicking on Macro → Data → Calculate expression and entering the formula

Enter the variables in the calc macro

4

We added an Input Form macro to display all the Manual Inputs together and your BMI calculator is ready.

The Calculate BMI form

{#inputForm -[title=Calculate BMI][hideSectionVisibility=1]#}
{#varSet {#input -[desc=Weight (in Kg)]#} -[name=weight][hide=1]#}{#varSet {#input -[desc=Height in meters]#} -[name=height][hide=1]#}
BMI: {#calc {#var weight#}/({#var height#}*{#var height#})#}
	

Still need help? Contact Us Contact Us