[EMAIL PROTECTED] wrote:


...
Yes, you are right - both should return the error "unacceptable array index list".

I'd have to disagree: 0 is a perfectly valid length for a string: it has no characters. However, how can a string have -1 characters?


If the QL had used a$(start, numb_of_chars) like most basics' MID$(a$, start, numb_of_chars), then this odd behaviour wouldn't have occurred.

It's useful if you have a delimiter separated string, eg: "nobody:x:99:99::/:/bin/false" (colon (:) delimited). The lengths of each element are 6, 1, 2, 2, 0, 1, 10. Which equate to positions: 1 TO 6, 8 TO 8, 10 TO 11, 13 TO 14, ???, 17 TO 17, 19 TO 28. We have a problem with the 5th (empty) element.

The start of element n is position of the [(n-1)th delimiter + 1] (the 0th delimiter is position just before the string, is position 0), and the end of the element is the position of the [nth delimiter - 1] (the string is assumed to be immediately followed by an infinite number of delimiters) [with the length of the element as end - start + 1]. With the 5th element in the example we get:

    start  = pos(4th colon) + 1 = 15 + 1      = 16
    end    = pos(5th colon) - 1 = 16 - 1      = 15
    length = end - start + 1    = 15 - 16 + 1 = 0

If a$(start TO start - 1) is disallowed, how would you legally slice an empty ("") string?

Why the odd behaviour on the first example, I have no idea - it happens in v3.03 BTW




          • ... Dave P
            • ... "Phoebus R. Dokos (Φοίβος Ρ. Ντόκος)"
            • ... "Phoebus R. Dokos (Φοίβος Ρ. Ντόκος)"
          • ... Bill Waugh
          • ... Marcel Kilgus
  • ... P Witte
  • ... Claude Mourier 00
  • ... RWAPSoftware
    • Robert Newson

Reply via email to