There's more to experience when you log in!
Another follow-up to yesterdays event. @Warren Vick? can you share the top tip for omitting zero values from being displayed when labelling objects?
Hi John. Yes, happy to.
I demonstrated Ordnance Survey AddressBase Plus with almost 39 million address records in a 80GB+ TAB Extended file set. One of the fields is the house number (integer), which is quite nice to use for labeling over building polygons or satellite/aerial imagery. A problem occurs, however, when a building as a name rather than a number. Since TAB(X) doesn’t have the concept of NULL, the value zero is used in this data set. Simple labeling causes wanted zeros to appear on the map. There’s a quick trick to display house numbers, except zeros using the format$() function. This MapBasic function is quite useful as it can present numbers in a number of formats. The function can be used if you label with an “Expression” with:
I also have a more advanced expression which shows the building name, if there is one, alternatively the number where non-zero (as above). Interested in this one too? Equipped with MapBasic functions, in particular left$(), you can do all sorts of conditional labeling in Pro. Perhaps a good topic for a presentation sometime.
That's a very handy new function, especially for labeling, although I might get confused with the mathematical iff!
I presume the expression for the problem above would be something like:
iif(house_number, house_number, "")
or to conditionally bring in the building name:
iif(building_name<>"",building_name, iif(house_number, house_number, ""))
This is all much easier than string/expression wrangling with left$(), len(), etc.
For multiple conditions you can also use the new Cond() function.
Where the IIf() is similar to the If statement, the Cond() is similar to the Do Case statement.
Your example could look like:
Cond(1, building_name<>"", building_name, house_number, house_number, "")
The last "" is the default value returned if none of the other conditions are met.
@Warren Vick? - so what was the more advanced expression that you had used?
And were you using it to update a new column with an address string?
Check this article for the "advanced expression" that you needed to use before we added the IIf() and Cond() functions: