Feature: Hidden fields

If you have spent any length of time developing apps with Calcapp, you have likely found yourself having to include the same formula fragments in many different formulas. If you need to convert an input number to a different unit before using the converted number in three different formulas, you need to include the conversion logic three times.

You could, of course, create an output field calculating the converted value and simply reference that field in your three formulas. That would work nicely, but would introduce yet another visible field, perhaps needlessly cluttering your user interface.

To solve this problem, our upcoming release introduces hidden fields. A hidden field is just like a normal field, but is never shown to your users. Make a field hidden by toggling its Hidden property in the inspector:

A hidden field

When you make a field hidden, properties that are no longer relevant (such as the number of decimal places a number should be formatted with) are hidden from view. Instead of showing the caption and initial value of the field, the app designer shows the field name and as much of the formula that can fit on one line.

The top drop-down menu in the inspector normally allows you to set various characteristics of a field, such as whether it should allow the user to enter dates or whether it should look like a switch. When you set these characteristics, you implicitly also set the type of the field. A field holds either a number, a logical value (TRUE or FALSE) or a text string. When you ask that a field should display a date, you also implicitly set its type to be a number.

When a field is hidden, you will find that this drop-down menu looks different:

The type drop-down menu in the inspector for hidden fields

In essence, you can only set the type of the field. As the field won’t be visible, all the visual characteristics you can normally set are no longer relevant and are not shown. If you click the Hidden switch to make a hidden field visible, you will find that all the visual properties are available to you once again, retaining any values you previously set.

From experience, we know that making a hidden field visible can be extremely useful when you’re developing an app. Flip the Hidden switch of your hidden fields during development to make them visible, thereby enabling you to verify that they calculate the correct values. Flip the switch again before sharing the app to ensure that your users don’t see your hidden fields.

Improving the temperature conversion formula

In the blog post announcing Calcapp’s support for list fields, we built a simple app converting degrees Celsius to degrees Fahrenheit and vice versa. This app asks the user to use a list field (a drop-down menu) to select whether the entered number is in degrees Celsius or in degrees Fahrenheit.

The temperature conversion app uses this formula to calculate its result:

IF(ISBLANK(Input), BLANK(), IF(Conversion = "℃ to ℉", (9/5) * Input + 32, (5/9) * (Input - 32)))

This formula ensures that nothing is displayed if the user doesn’t enter an input value and that the proper unit (“℃” or “℉”) is displayed after the result. (Refer to the blog post for more information.) The problem is that the actual conversion formulas are mixed with the logic ensuring that the user interface is attractive, making for a long and unwieldy formula.

Using separate fields to perform the conversion is ideal, with one field converting the input value from degrees Fahrenheit to degrees Celsius and the second field doing the opposite conversion. The result formula can then reference these two fields. As we don’t want the two conversion fields to be visible to the user, we make them hidden.

All in all, these are the formulas of our three fields:

Celsius: (5/9) * (Input - 32)

Fahrenheit: (9/5) * Input + 32

Result: IF(ISBLANK(Input), BLANK(), IF(Conversion = "℃ to ℉", Fahrenheit & " ℉", Celsius & " ℃"))

As you can see, the hidden fields are indeed hidden when we preview the app:

List fields with formula

« Feature: List fields Release: Our September, 2016 update is now available »