Understanding dot notation

Understanding dot notation


All command and features in mapping strings revolve around a basic concept, which is providing the ability to inspect and modify character data.  The data that is being operated on at any given point may originate either from the source string or the result string.  When a command can reference and copy data directly from the source string, it is a copying command.  When it can only refer to data already in the result string, it is a modifying command.


To keep the various command codes as simple as possible, the design has considered which data origin a given command is likely to need to reference the most often, and that data origin is the mapping command’s default origin.  For example the case alteration command UC is applied by default to the result string, and so the UC command has the result string as its default data origin.


In addition to commands which operate on the result string by default, mapping commands that take a column-range operand can use the . dot symbol to indicate that a reference to the current contents of the result string is being made.  This is known as dot notation.


If a dot symbol precedes a column reference, like .1-4, that column reference is used to select a substring from the current contents of the result string.  You can use dot notation anywhere a regular column reference is allowed, either by itself, or as part of a column-range operand on a particular command code.  



Visually, think of dot notation like this:


       “result string”    { copying commands with dot notation  … }

 “revised result string”


You may not often need to use this technique, but it is available if you do.  The main reason for dot notation is to allow a copying command to be used as a modifying command instead.  For example, the command AX is a copying command.  Thus:


    1. A mapping item of AX1-4 would convert the first 4 characters of the source string into 8 hex-digit characters and place them in the result string


    1. A mapping item of AX1+ would convert the entire source string into hex-digit characters, producing a string twice as long and place them in the result string.


    1. Because of the auto-reference feature, if a simple AX command is issued with no column numbers after it,  it implies that the complete source string is referenced by the AX command, and the value it produces is placed into the result string.  So, if the source string contained “abcd” and you issued this AX command as the first thing in the mapping string, it would convert those 4 characters, then place the converted into the result string, producing “61626364”.


    1. A mapping item of AX.1-4 would convert the first 4 characters of the result string into 8 hex-digit characters.  Those 8 characters would be appended to the end of the result string.  So, if the result string already contained “abcd” and you issued this command, it would convert those 4 characters, then place the converted result after those 4 characters that were already there, producing “abcd61626364”.


    1. A mapping item of AX. would convert the entire result string into hex-digit characters, producing a string three times as long (the original data put 2 hex digits for each original character); those characters would be appended to the end of the result string.  Note that AX.1+ and AX. so happen to produce the same result, since a lone . dot references the entire result string, and it implies AX.1+


    1. If you specify dot notation to force a copying command to modify result string data, the dot notation will cause the auto copy feature normally associated with modifying commands to take place.


For example, if your source string contains "abcd" and you issue a mapping command of AX.1-4, and if this were your only mapping command, the dot notation would cause the source string to be initially copied to the result string as "abcd" and then columns 1-4 of the result string (in this case, the entire value) would have the AX command applied to it, and the value it produces is placed at the end of the "abcd" in the result string, giving a revised result string value of “abcd61626364”.


Usually, you wouldn't want both the original value of “abcd” and the results of the AX command joined together like this.  In this example, the correct way to do this would be to note that, because AX is already a copying command, you can convert the source string directly simply by using AX alone without the .1-4 part, giving a final value of “61626364”.  The best way to understand this is to experiment using various commands on some test data, and observe how they operate.  You can also use the Mapping Test Program for learning and experimentation.  The Mapping Test Program is discussed at the end of this article.


When you read the descriptions below, pay close attention as to whether the mapping item involves the source string, the result string, or both.  Look for the syntax description of the column-reference operand under each command's documentation in the Quick Reference.  You will find under each command a note as to whether the command is a copying command or a modifying command.  A few specialized commands are neither copying nor modifying commands.


Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator