[users] Re: Help with writing macro

2011-09-21 Thread Johnny Rosenberg
2011/9/20 Grzesiek Sójka p...@sojka.co:
 Hi there.

 I need to write a macro accepting variable length parameter list. I was
 tryint to googl but no luck. So the question is how to write (preferably in
 OpenOffice Basic) macro accepting variable length parameter list.

 Thanks in advance for any help

Can you give an example? I'm not sure what you mean by ”accepting
variable length parameter list”. What is the user supposed to do and
what is the macro supposed to do with it? Is the macro supposed to run
in Calc, Writer or what?


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ



 --
 -
 To unsubscribe send email to users-unsubscr...@openoffice.org
 For additional commands send email to sy...@openoffice.org
 with Subject: help

-- 
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Grzesiek Sójka

On 09/21/11 17:08, Johnny Rosenberg wrote:


Can you give an example? I'm not sure what you mean by ”accepting
variable length parameter list”.
I do need to get some kind of statistic-like data. So I can not make any 
assumptions on the number of the results specified. Lets say that my 
macro is called MACRO. It should be possible to put in the spreadsheet 
cell something like:

=MACRO(A13;D15;C1)
and also:
=MACRO(A2;D1)
Then our MACRO should return some kind of numerical data calculated 
using all the values from all the cells specified. For the star it may 
be for example the sum of all values.



What is the user supposed to do and
what is the macro supposed to do with it? Is the macro supposed to run
in Calc, Writer or what?

It should be used in Calc.
--
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Johnny Rosenberg
2011/9/21 Grzesiek Sójka p...@sojka.co:
 On 09/21/11 17:08, Johnny Rosenberg wrote:

 Can you give an example? I'm not sure what you mean by ”accepting
 variable length parameter list”.

 I do need to get some kind of statistic-like data. So I can not make any
 assumptions on the number of the results specified. Lets say that my macro
 is called MACRO. It should be possible to put in the spreadsheet cell
 something like:
 =MACRO(A13;D15;C1)
 and also:
 =MACRO(A2;D1)
 Then our MACRO should return some kind of numerical data calculated using
 all the values from all the cells specified. For the star it may be for
 example the sum of all values.

 What is the user supposed to do and
 what is the macro supposed to do with it? Is the macro supposed to run
 in Calc, Writer or what?

 It should be used in Calc.

I haven't done this myself, but I would try to use ”Optional” and
”IsMissing”, something like this:

Function MyFunction(A As Double, Optional B As Double, Optional C As
Double) As Double
'   Some code
If IsMissing(B) Then
'   Do something
EndIf
More code
End Function



Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ
-- 
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Grzegorz Sójka

On 09/21/11 18:53, Johnny Rosenberg wrote:

I haven't done this myself, but I would try to use ”Optional” and
”IsMissing”, something like this:

Function MyFunction(A As Double, Optional B As Double, Optional C As
Double) As Double
'   Some code
If IsMissing(B) Then
'   Do something
EndIf
More code
End Function
This seems to be some kind of a solution. If I'm not wrong this actually 
implies that there is not more than 3 arguments. The problem is that 
there could be like 10 (or even more). Is there a way of dealing with 
such case without specifying 9 arguments as optional??

--
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Dennis E. Hamilton
From your example, there is potentially another way to solve this in Calc 
formulas.

You can specify a list of references that would then be a single parameter:

=MACRO(A13~D15~C1)

For example,
 
=SUM(A13~D15~C1)

works.



The question is, how does the definition of the macro specify that it accepts a 
reference list, and how does the definition of the macro enumerate the cells in 
the list to determine its result.

If this can be treated as a dimensioned parameter of variable length, then you 
have one way to make this work.

I don't know the macro capabilities well enough to know if there is a 
straightforward way to handle this case.

 - Dennis

PS: In future, it might be possible to also use an in-line array for the 
variable-length parameter list.  It appears that arrays with non-constant terms 
are not yet supported.  E.g.,

=MACRO({A13;D15;C1}) 

doesn't appear to work in LibreOffice Calc at this time.  Again, there needs to 
be some way to work on the individual elements in the array as part of the 
MACRO definition.



-Original Message-
From: Grzesiek Sójka [mailto:p...@sojka.co] 
Sent: Wednesday, September 21, 2011 08:39
To: users@openoffice.org
Subject: [users] Re: Help with writing macro

On 09/21/11 17:08, Johnny Rosenberg wrote:

 Can you give an example? I'm not sure what you mean by ”accepting
 variable length parameter list”.
I do need to get some kind of statistic-like data. So I can not make any 
assumptions on the number of the results specified. Lets say that my 
macro is called MACRO. It should be possible to put in the spreadsheet 
cell something like:
=MACRO(A13;D15;C1)
and also:
=MACRO(A2;D1)
Then our MACRO should return some kind of numerical data calculated 
using all the values from all the cells specified. For the star it may 
be for example the sum of all values.

 What is the user supposed to do and
 what is the macro supposed to do with it? Is the macro supposed to run
 in Calc, Writer or what?
It should be used in Calc.
-- 
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help

-- 
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Tom Keene
How about passing your data in an array.  Then you only need one parameter.

On Sep 21, 2011, at 12:53 PM, Grzegorz Sójka wrote:

 On 09/21/11 18:53, Johnny Rosenberg wrote:
 I haven't done this myself, but I would try to use ”Optional” and
 ”IsMissing”, something like this:
 
 Function MyFunction(A As Double, Optional B As Double, Optional C As
 Double) As Double
 'Some code
  If IsMissing(B) Then
 'Do something
  EndIf
  More code
 End Function
 This seems to be some kind of a solution. If I'm not wrong this actually 
 implies that there is not more than 3 arguments. The problem is that there 
 could be like 10 (or even more). Is there a way of dealing with such case 
 without specifying 9 arguments as optional??
 -- 
 -
 To unsubscribe send email to users-unsubscr...@openoffice.org
 For additional commands send email to sy...@openoffice.org
 with Subject: help

-- 
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Grzesiek Sójka

On 09/21/11 23:12, Tom Keene wrote:

How about passing your data in an array.  Then you only need one parameter.
Could you please be a little more specific?? I do not have to much 
experience in writing macros.

--
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-21 Thread Andrew Douglas Pitonyak

On 09/20/2011 04:48 PM, Grzesiek Sójka wrote:
I need to write a macro accepting variable length parameter list. I 
was tryint to googl but no luck. So the question is how to write 
(preferably in OpenOffice Basic) macro accepting variable length 
parameter list.
I am not aware of any way to write a macro that accepts an totally 
arbitrary number of parameters. That said:


*** (1)
You can specify as many arguments as you desire to be optional. The 
disadvantage is that you must then set an upper bound on the number of 
arguments, and then you must also test each argument to see if it was 
included.


*** (2)
When you call a macro as a function from Calc, ranges are packaged and 
sent as an array, which means that you require only a single variable 
for each range included. This may, or may not, be of use.


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php

--
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


[users] Re: Help with writing macro

2011-09-20 Thread Anthony Chilco
Hi GS,
Check this out:
http://www.pitonyak.org/oo.php
tc





From: Grzesiek Sójka p...@sojka.co
To: users@openoffice.org
Sent: Tuesday, September 20, 2011 4:48:46 PM
Subject: [users] Help with writing  macro

Hi there.

I need to write a macro accepting variable length parameter list. I was tryint 
to googl but no luck. So the question is how to write (preferably in 
OpenOffice Basic) macro accepting variable length parameter list.

Thanks in advance for any help

-- -
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help


-- 
-
To unsubscribe send email to users-unsubscr...@openoffice.org
For additional commands send email to sy...@openoffice.org
with Subject: help