
ptp
USA
Asked
— Edited

The code below does not work:Code:
1: ClearVariables()
2: $buffer = "foo;bar;quux"
3: $sepPos = 3
4: $len0 = Length($buffer)-$sepPos-1
error:
Quote:
Error on line 4: Operator '-' invalid for strings.
1st attempt with a different code:
Code:
1: ClearVariables()
2: $buffer = "foo;bar;quux"
3: $sepPos = 3
4: $len1 = Length($buffer) - $sepPos
5: $len1 = $len1 - $sepPos
same error.
2nd attempt (success)
Code:
1: ClearVariables()
2: $buffer = "foo;bar;quux"
3: $sepPos = 3
4: $len2 = Length($buffer)
5: $len2 = $len2 - $sepPos - 1
it seems the the parser assumes Length function returns a string ?
I ran into this issue myself, if you don't want to separate it over multiple lines you can cast the length in an int. I guess it is just one of the limitations of not declaring variable types.
Code:
Code:
i had other similar issues with other functions too.
I don't agree with "it's just one of the limitations of not declaring variable types" mainly because of this:
Code:
and it works, one function and two math operations.
Length() is returning the correct type (integer), only when combined behaves differently i'm guessing is really a parser issue.
Makes sense.Code:
Code:
Code:
Code:
Thanks a lot Dj! Again, really, I appreciate the incredible dedication and, in my particular case, the incredible patience! Sorry again for this day when I went nuts on the DHCP issue... I still think about it...