Build 7052, December 22 2006

Token Values and Expressions

Often when building an AllTopo project, you have a computed value at one annotation that you would like to display at another location.

For example in the project below the area is displayed at the closing point of inflection:

If we want to place the area in the center of the enclosed area, we have to manually add a point in the center and type in 6.31 Acres. If the perimeter changes, the displayed area does not follow.

Token-values have been implemented to assist with this task. Token values can be assigned values and then recalled as part of any annotation that follows in the annotation file.

Token-values have a Name and a Value. The name ALWAYS starts with an underscore and may contain any character except for space, tabs, quotes or '%'. To add the value of a user Token to a description, note (or other field) just enclose the token name within % characters.

For example, if the user token _Marko has a value of "6.31 Acres" then %_Marko% will evaluate to "6.31 Acres".

To assign a value to a user token, just add a token assignment to the Description or Note. In the example above we might use this syntax at the closing point:

 <Line CLOSE>
41.778877501 -112.286576266 NAD83; RA13; %_Marko="%AREA%"%

The area at closing point RA13 is evaluated and assigned to the user token _Marko. Then at a subsequent annotation we can display the value. In this case:

 <Line CLOSE>
41.778877501 -112.286576266 NAD83; RA13; %_Marko="%AREA%"%
<Pos C> <Line OFF>
41.779096453 N 112.284863207 W NAD83; _1; %_Marko%

results in this display

As you might expect, this token-value substitution can be used to generate a whole variety of other nifty consequences. Items enclosed within the quotes are evaluated when the assignment is made. Items enclosed within two sets of nested quotes will be evaluated when drawn.

As an example:

41.779488484 N 112.285279272 W NAD83; P1; %_Pollo="%name%|%utm%|%d%"%
41.778958140 N 112.285247185 W NAD83; P2; %_Pollo%

results in the Name, UTM coordinate and lat/lon coordinate of P1 (the top coordinate) being displayed as the label to P2 (the lower coordinate).

This is very dangerous with a potential of misleading the user by showing the coordinates for one coordinate at the location of another, but it may be of value for complex labeling applications.

The assignment statement need not be located in the description or note of an annotation. The assignment may be placed on it's own line within the annotation source file.

%_Pollo="%name%|%utm%|%d%"%
41.779488484 N 112.285279272 W NAD83; P1; %_Pollo%
41.778958140 N 112.285247185 W NAD83; P2; %_Pollo%

results in

This makes it easy to globally replace/change a style.