Talk:SmileBASIC (Petit Computer 3)/@comment-15296152-20150714050334/@comment-4509370-20150714124507

Testing go!

First off, arrays have to be specified with square brackets like DIM A[10] in SB.

However, even fixing that, after various testing there doesn't seem to be a way to return an array in an OUT-style function.

I guess there's no way of telling that you want OUT_A to be an array on the DEF line, so it gets confused.

DIM A[10],B[10] A[5] = 10 TESTME A,B PRINT B[5] END DEF TESTME IN_A,OUT_A OUT_A[5] = IN_A[5] END

^ However, this works fine.

DIM A[10],B[10] A[5] = 10 B=TESTME(A) PRINT B[5] END DEF TESTME(IN_A) DIM OUT_A[10] OUT_A[5] = IN_A[5] RETURN OUT_A END

^ And so does this.

Arrays are actually passed by reference.

DIM A[10],B[10] A[5] = 10 B=TESTME(A) PRINT B[5],A[4] END DEF TESTME(IN_A) INA[4]=11 DIM OUT_A[10] OUT_A[5] = IN_A[5] RETURN OUT_A END

^ This prints 10, 11.