Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

How Icon positions are numbered

Tech Computer Center logo

In Icon, the characters in a string are identified by their position, counting from 1. The positions refer to the gaps between the characters, not to the characters themselves. Positive numbers count from the left starting at 1, and nonpositive numbers count from the right starting at 0. For example, the positions of the gaps in the string "abc" are numbered like this:

   -3    -2    -1     0
    |  a  |  b  |  c  |
    1     2     3     4
So position 1 (or -3) refers to the position before the first character; position 2 (or -2) refers to the position before the second character; and so on. Position 0 is always the end of the string.
Next: Finding the size of an Icon string
See also: Using strings in Icon
Previous: Reading an input line in Icon
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Information Technology and Communications: Help System
ITC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

John Shipman,
Last updated: 1996/01/06 21:12:57 UT
QR two-dimensional bar code