Date: prev next · Thread: first prev next last
2020 Archives by date, by thread · List index

On 5/17/20 2:52 AM, Johnny Rosenberg wrote:
Den sön 17 maj 2020 kl 03:28 skrev Jim <>:

I started experimenting with calling a basic function from a python
script. I was surprised that without to much trouble I got it to work to
a certain extent.

I am working on linux Mint.

I started with a basic Sub I found. In it's original form it had 3 rgb
values hard coded and it popped up a message box that displayed the
color value from the rgb input. I rewrote it as a Function that took the
rgb values as parameters.

Here is the basic:

Function ColorExampleFunc(r as long, g as long, b as long)
Dim lVar As Long
lVar = rgb(207,231,245)
msgbox "The color " & lVar & " consists of:" & Chr(13) &_
"red= " & red(lVar) & Chr(13)&_
"green= " & green(lVar) & Chr(13)&_
"blue= " & blue(lVar) & Chr(13) , 64,"colors"

end function

Here is the python:
import os

result = os.system('soffice

This works as it will pop up the message box with the color value
displayed. What I need to do is capture that color value (which is
usually an eight digit number) in variable in the python script.

I printed result and it was equal to 0.

Well, you "rewrote it as a function", except that you didn't. The
difference between subroutines and functions (at least in Basic), is that
functions returns something. Yours don't, as far as I can see.
To return a value in Basic (at least LibreOffice Basic), you just set a
value to the function itself:


I'm not sure what those eight digit numbers you are looking for are. Is it
something like b+g×2⁸+r×2¹⁶?

It is the result of lVar = rgb(207,231,245), which in this case is 13625333 and that is the color value of blue_classic.

So if I rewrote the function as:

Function ColorExampleFunc(r as long, g as long, b as long)
Dim lVar As Long
lVar = rgb(207,231,245)
ColorExampleFunc = lVar
end function

and called it from libreoffice basic it would return 13625333? I ask because when I call it from my python script it returns 0. If I know it is working in basic then I can concentrate on figuring out what is happening on the python part.

Thanks, Jim

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
Privacy Policy:


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.