Tech Tip: Some commands use a different convention to describe a selection or range
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: June 15, 2018
When dealing with strings in 4D, some commands work with a "Range" of characters while other commands work with a "Selection" of characters. It is important to understand the difference between the two and to use the correct convention for the command that is being used.
The two two conventions are range and selection.
Let's look at the example string of ABCDE.
Range counts using the "space" between each characters. So the range representing the entire string of ABCDE is 1-6, as illustrated below:
| a | b | c | d | e |
1 2 3 4 5 6
Selection counts the individual character positions. A selection representing the entire string of ABCDE is 1-5, as illustrated below:
a b c d e
1 2 3 4 5
Now let's look at the example word of teabags.
Let's see how the substrinbg bag could be represented using these different conventions.
For the commands that work with range it would be represented like this:
| t | e | a | b | a | g | s |
1 2 3 4 5 6 7 8
start:=4
end:=7
For commands that work with a selection of characters it would be represented like this:
t e a b a g s
1 2 3 4 5 6 7
start:=4
end:=6
It is therefore important to look at the command reference to determine which convention is used by the command you are working with.