ASSIGN values to elements in MAP

When assigning values to elements in MAP, consider the following:

  • The default value of an element in the MAP is an empty text (TEXT), 0 (NUMBER), or FALSE (BOOL).
  • If a Template script tries to use an element that is not present in the MAP, the element is added to the MAP with the default value. This new element is then operated on.
  • The ASSIGN statement must be used to add an element to MAP or to assign a value to an element.
  • Indices are case-sensitive and word processor instructions are ignored. If the setting EnhancedUnicodeMaps is disabled in the KCM Core Administrator, indices are also limited to the Latin-1 character set and all characters not in this set are ignored as well.

To test the presence of an element without creating it, use the functions as shown here.

key_used_in_text_map
key_used_in_number_map
key_used_in_bool_map
key_used_in_fieldset_map
key_used_in_struct_map

To access an element with a known key or index value, use the functions as shown here.

ASSIGN variable_name := map_name[ "key" ] 

An example of how to add an element and assign a value to that element in MAP is provided here. The MAP element with the text_expression index now contains the value value_expression.

ASSIGN map_name [ "text_expression" ] := value_expression 

An example of how to declare MAP as parameter of a Procedure or a Function is provided here.

FUNC TEXT example_func ( MAP TEXT map_name )

An example of how to pass MAP to a procedure or a function is provided here.

APROC example_proc ( map_name )

An example of how to use MAP as a VALUES list in INTERACT is provided here.

INTERACT "Test" 
			QUESTION "Question" 
			VALUES ( map_name ) 
			ANSWER variable 

You can assign values of TEXT MAP and FIELDSET to each other, or merge them.