[Solved] Run a macro in calc

edit by @karolus crosspost of https://forum.openoffice.org/en/forum/viewtopic.php?p=541588#p541588

How do I use a macro in a cell to call a function that has another cell as a parameter?

I’ve tried,

Thanks,

Mike.
P.S. I hope that image becomes visible.

I forgot to add, if I change A1 (hello world) is says that dat (the parameter) is undefined.

Thanks,

Mike.

Hello, Mike!
Yes, the screenshot is visible.
You described the strange behavior of the program. I just repeated your test code, pasted the formula into cell A2 and changed cell A1 several times - everything works without errors. Please tell us more about your LibreOffice and operating system.

baSICK has no keyword return to return something, the equivalent is

function myConvert( dat as variant ) as variant
    myConvert = dat
end function   

@JohnSUN why do you say it works?!

Thank you. That fixed it but I’m sure I tried that before (as used by VBA), obviously, I had something else wrong too.

Mike.
Edit, I’m thinking JohnSUN must have not been using basic.
Edit2, why does it say dat isn’t defined rather than return is a syntax error?
Edit3, realised that return is valid but the dat after it isn’t. However, still seems an incorrect error.

Oh, “why, why”! Just because I was wrong! Looking at the screenshot, I opened IDE and just out of habit, I wrote it down correctly myConvert = dat, and not as shown in the screenshot. Yes @karolus , you are more attentive than me :grinning:

I don’t have the faintest idea why this behaves like this, but BASIC is just BÄH_SICK!

Think I might have to try one of the other languages. Any suggestions having come from a C background.

Because the word return itself is not an error, it’s just used in a different construction

And, that’s what my third edit said.

@pommie Yes, we wrote these messages at the same time, synchronously :smile:

the downside is: Calc does only a lookup in ~basic/Standard for UDFs (UserDefinedFunctions) for other languages than BASIC you need to build whole some_addinn.oxt with boilerplate around.

ah interesting, BASIC has key-word return and it seems its behaivior is like raise in python