Referencing row indices
Each character of a string has its own number (called
index), and indexing in the programming language Pascal starts from one. That is, the first character has index 1, the second has index 2, and so on.
String characters can be accessed by indexes, which are indicated in square brackets
s[i]
.
Example
String S |
H |
e |
l |
l |
o |
Index |
S[1] |
S[2] |
S[3] |
S[4] |
S[5] |
P.S. Many string methods in PascalABC.NET assume that strings are indexed from zero. We won't be using string methods that work with zero-based indexes for the time being. There are equivalent replacements for these with external functions that assume that rows are indexed from 1.