General area when it fits no where else

Moderator: Mmiscool

User avatar
By Electroguard
#45609 This tip may be useful for anyone wanting to split a string into left and right bits...

I don't think you can split a string into left and right bits very easily using left() and right() functions, because the left() value is the split position, but the right() value is the number of characters to take, therefore is not the split position, which means you need to subtract the split position from the length to get the remainder value (which is fine, but not what I expected).

However, I've found that if you use mid() instead of right() - just giving it the start point but leaving out the length - then it actually returns everything after the split position anyway, eg:

Code: Select allmsg = "Peter Paul and Mary"
pos = instr(msg, "Paul")
let leftbit = left(msg,pos - 1)
let rightbit = mid(msg,pos)
print "Left bit=" & leftbit & " Right bit=" & rightbit