02-07-2019, 10:02 PM
ShaunBebbers Wrote:Hello,
I am looking at string manipulation, particularly in terms of deleting the last character from a string.
...
It's the "delete last character" routine that I'm having trouble with. the b$(0 TO LEN(b$)-1) isn't doing what I'm expecting, i.e., if the contents of b$ are:
Code:12345
I want c$ to be:
Code:1234
and therefore be passed back to the b$ string before returning.
Many thanks for any help or advice.
Regards,
Shaun.
Have you tried with
Code:
b$(0 TO LEN(b$) - 2)
Since by default ZX Basic strings are 0-based (the standard in BASIC is 1-based, that is, starting from position 1), LEN(b$) - 1 is the position of the last character. So LEN(b$) - 2 is the 2nd to last.
Try this and tell me, please. :roll: