LoginLogin
Might make SBS readonly: thread

COPYing DATA into zero-length array

Root / SmileBASIC Bug Reports / [.]

MZ952Created:
Nope.
DIM A[0]
COPY A,@0
@0
DATA 1
Subscript out of range in... This was an error a while back with copying between just arrays themselves (now fixed), but I think this has always been the case with copying from @ labels (wasn't fixed).

COPY Destination array [,destination offset], "@Label string" [,Number of copy data items] (<-2/2) Oh wait, the manual states: "... data items will be read according to the number of elements in the copy destination array." Okay, so, the "array" in this case is the list of data items proceeding DATA. "Array" might be a typo, idk, this is under the second tab of the COPY manual page, under Number of copy data items. Gotta be a typo (unless DATA is somehow treated like an array?). Anyway, if you omit the parameter, then it copies LEN(ARY[]) items. Still an error imo because if the length is zero, it should copy zero elements rather than throw an error. If you specify 0 in the optional parameter, it does not error. So,
DIM A[0]
COPY A,@0,LEN(A)
@0
DATA 1
to be on the safe side.

It's not a typo, COPY A,@0 is normally the same as COPY A,@0,LEN(A) (except for this bug, when LEN(A) is 0)

Oh yeah I misinterpreted what I read.