Suppressing error values in shared apps

Have you ever created an app using Calcapp only to find that your app displays error values in red? These error values are there to help you diagnose formula errors, but look unprofessional in apps you distribute to end users. As such, error values won’t show up in shared apps once we release our October update.

Here are two pictures of a shared app dividing numbers. The first one depicts how it appears before the October update and the second one how it will appear after:

That’s the gist of it. If you’re curious to learn more, read on.

Background

Our June release completely overhauled how Calcapp handles errors in formulas. Formula error values are returned instead of actual values when a function is given an unexpected parameter or when an operator (such as division) is given an unexpected operand. (“Parameters” to operators are known as operands.) For instance, if you try to divide a number by zero, an error value representing division by zero is returned. Functions typically return error values when they are passed an unexpected parameter, such as a negative number.

If an error value is returned instead of an ordinary value, fields display them using a short code, such as “#DIV/0!” for division by zero. These codes are displayed in red.

If the divisor is zero in the following app, an error value is shown:

A division by zero error, with an explicit zero

A field that is blank contains what is known as a blank value. (Programmers typically refer to these values as “null” or “nil.”) When you use a blank value in an expression, it is often interpreted as zero. That’s why you get error values in apps that generally disappear when you start entering numbers (unless, of course, you enter zero.) That means that the error value shown in the screen above will also be displayed even if the user doesn’t enter anything into either field (it tries to divide zero by zero):

A division by zero error, with implicit zeroes

Suppressing error values

You can use various functions to handle error values: ISERROR returns TRUE if, and only if, the given value is an error and ERROR.TYPE returns an error code corresponding to the type of the given error value. (There’s more information in the function browser.)

The most useful error handling function, though, is likely IFERROR, which you can use to suppress the display of error values. The second parameter is the value which should be returned if the first parameter is an error value. Otherwise, the first parameter is returned. That means that you can use the expression IFERROR(Field1 / Field2, BLANK()) to return a blank value if dividing Field1 by Field2 doesn’t work, effectively suppressing the error value.

We have found that very few apps gracefully handle errors, though. Error values are shown to help you diagnose why your formulas don’t work as intended and are not intended to be shown to users of your apps. As such, starting with the October release, they will be hidden from shared apps (and only from shared apps). Apps shown in Calcapp Creator’s preview pane will still show error values, as will apps run through Calcapp Connect (where you sign in and explicitly select an app).

« Feature: Keyboard shortcuts Feature: Reset fields to their initial values »