Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
String Slicing (*solved*)
#1
Not sure whether this is as intended, but it's not quite compatible with Sinclair Basic:

LET K$="1234567890"
PRINT K$(TO 3)
PRINT K$( 3 TO)

All seems to compile - though strings are numbered from 0, whereas Sinclair basic numbers them from 1.

So ZX Basic gives the output:

1234, where Sinclair basic would give the output 123

If the aim is to be able to compile Sinclair Basic, we're not there with that one. (Perhaps a switch, or configurable option?)

Also:

Print K$(3) fails. We would need to use k$(3 TO 3). Is this a bug?

PRINT K$( TO ) also fails, and ZX Basic allows it. It's an unusual corner case, though - it means the same thing as just K$. If it was to be supported for compatibility, a preprocessor tweak ought to be able to optimize it to disappear before the compiler saw it.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)