We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

LO BASIC : Passing array From Procedure to Function and Function returning array to Procedure

asked 2020-05-12 08:34:52 +0200

lonk gravatar image

updated 2020-05-12 08:35:38 +0200

Is it possible ?

Please help modify LO BASIC codes in attached file.C:\fakepath\PassArrayFromProcedureToFunctionAndFunctionReturnsArrayToProcedure.ods

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-05-12 13:28:57 +0200

Lupp gravatar image

updated 2020-05-12 13:53:44 +0200

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:
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
edit flag offensive delete link more


Dear @Lupp,

Thank you so much for your assistance and your concern.

lonk gravatar imagelonk ( 2020-05-13 08:28:04 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-05-12 08:34:52 +0200

Seen: 104 times

Last updated: May 12 '20