Closed dynamicboy closed 4 weeks ago
Arrays operations in Small Basic (hence in sV) creates a new modified array. It is difficult to teach references to kids and beginners. This makes arrays easier but slower. This applies to one and multi dimensional arrays. I made one exception to enhance large array initialization, by allowing to use Array.Append to modify the array without crating a new one, but the array has to contain at least one element before calling Append. In such case, if you pass the array as a parameter, it will be passed by ref. For more information, read the notes in the Array type and the Array.Append method in the sVB pdf. And don't forget to close this issue. Thanks.
From: dynamicboy @.> Sent: Tuesday, June 18, 2024 11:47 AM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Subscribed @.***> Subject: [VBAndCs/sVB-Small-Visual-Basic] Modifications to a multidimensional array passed as a function parameter are not persisted. (Issue #69)
version: sVB 3.0.7.4 details: Modifications to a multidimensional array passed as a function parameter are not persisted. code :
A[1]["Name"] = "Name" A[1]["Path"] = "Path"
TW.WriteLine("Before FillArray(A): ") PrintArray(A)
FillArray(A)
TW.WriteLine("After FillArray(A): ") PrintArray(A)
Function FillArray(arrayA) For i = 1 To 5 arrayA[i]["Name"] = "Name" + i arrayA[i]["Path"] = "Path" + i Next Return 0 EndFunction
Function PrintArray(arrayA) For i = 1 To 1 TW.WriteLine(arrayA[i]["Name"]) TW.WriteLine(arrayA[i]["Path"]) Next Return 0 EndFunction
Output:
Before FillArray(A): Name Path After FillArray(A): Name Path Press any key to close the window...
Screenshot:
Tips: One dementional array works fine, as shown in function FillArray Multi-dementional array can be passed into function to read.
— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/69, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVQ52GP7S447QS65PJLZIAM4RAVCNFSM6AAAAABJP3PRN6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2TSNRWGYZTGMI. You are receiving this because you are subscribed to this thread.Message ID: @.***>
version: sVB 3.0.7.4 details: Modifications to a multidimensional array passed as a function parameter are not persisted. code :
Output:
Screenshot:
Tips: One dementional array works fine Multi-dementional array can be passed into function to read.