Is it possible ?
Please help modify LO BASIC codes in attached file.PassArrayFromProcedureToFunctionAndFunctionReturnsArrayToProcedure.ods
Is it possible ?
Please help modify LO BASIC codes in attached file.PassArrayFromProcedureToFunctionAndFunctionReturnsArrayToProcedure.ods
The way arrays are handled results in getting them passed factually the ByRef way even if ByVal is expected or erxplicitly specified.
Your code contained lots of strange attempts due to misunderstandings. The tried BubbleSort contained an error.
Concerning the problem of passing arrays ByVal effectively I added a helper module from my toolbox previously published here. (Only parts of the module are actually used then.)
Concerning the mentioned misunderstandings and the BubbleSort error I made a reworked version from which you may learn. It is contained in this attachment:
ask243812guess_CcreateSortedArrayKeepingtheOriginal_1.ods.
If you are decisive to write “macros” in Basic, you should start at the beginning. Unfortunately I cannot point you to really good teaching texts. The famous texts by Andrew Pitonyak aren’t exactly for beginners and are very much concerned about the usage of the uno API
with Basic programming.
===Edit 2020-05-12 about 12:00UTC===
To avoid the need of using the mentioned toolbox you can, of course, use specialized code for making a copy of a simple one-dimensional array like:
l = Lbound(origArray) : u = Ubound(origArray)
Dim copiedArray(l To u)
For j = l To u
copiedArray(j) = origArray(j)
Next j