About pseudo objects with Basic code ...

Hi,

1. I'm using pseudo object style when I'm coding with Basic. What about putting my  pseudo basic objects into library ? It looks like I couldn't use new to create object if I put them into a library ...

2. Can I access global variable into a librarie ?

3. Do you know a trik to simulate reference like "This" pointer ?

4. What about objects with nexts LibreOffice/OpenOffice versions ? Do I need to use python next ?

Patrick

Hi Patrick,

Hi,

1. I'm using pseudo object style when I'm coding with Basic.

Please add an code example of this "pseudo object style".

Kind regards
Regina

Hi...

In this example: https://docs.empresalibre.net/f/0bd013d0edcc44f79456/?dl=1

You can see an example how to used classess in Basic, included simulate "self" (This)

Best regards

Ok, with a factory for self variable into pseudo objects. I was thinking of this solution already, but I was hoping a better solution in next version ...
- Do you need this pseudo object code could be better object model complient next day ?
- Or do you think python will be a better way for OpenOffice/LibreOffice futur ?

Of course, definitely, Python is much better, I always recommend; learn and used Python with LibreOffice

Best regards

Howdy, Mauricio, Patrick

I am curious as to why you think python is always the better choice? (ie.
error handling, or whatever; or is it just always so in Patrick's use case
and the example code you supplied there)

Also, I you don't mind me asking. I'm new python scripting in LibreOffice.

Do you have recommendations for setting up tools with LibreOffice to with
Python scripts and perhaps then turning those into an extension.

Right now I am using the following: LibreOffice 6.x, APSO (latest), MRI
(latest), MS Video Code. Which of those would, if any, would you suggest I
look at replacing.

Thanks and best wishes,

Hi :slight_smile:
I think the Devs Mailing list or IPA, IIRC or whatever is prolly better at
giving a good answer to that. They may be annoyed as it's prolly not what
they usually post to there. Maybe it's best to try the QA Team?

There used to be a "mentoring" program to help people start to code for
LibreOffice.

I think LibreOffice is mainly Python but with significant chunks of C, C++
and C# and smaller amounts of other code. I think pretty much all the Java
has been over-written in Python now.

There may be some devs on this mailinglist who can answer you but it
doesn't hurt to have other places to ask too. Actually i thought you were
one of our devs but there we go. I know you have done a lot for LO.
Good luck and regards from
a Tom :slight_smile:

Howdy Tom,

Well, I was specifically asking Mauricio, after looking over the example
basic code particularly, I am interested in his thoughts.

As for this being the user mailing list, macros are user level question I
would think, Basic is assumed usually, but Python is just as valid and
about as easily done these only to drop in a couple of extensions. Maybe
it is a power user question, but still a user question, yes?

However, I suppose your'e right when moving on to talking about generating
extension packages from macros libraries (basic or python).

Thanks

Hi :slight_smile:
Ahh, yes. Here is often good for anything. Macros are definitely for this
mailing list.

I remember learning one form of basic in the 80s and that was pretty easy
back then. I gather it's become over-complicated now so i'm starting again
from Scratch and then Python - or kinda both at the same time(ish). It
seems more robust and more standardised.

Regards from a Tom :slight_smile:

Hi...

I'm sorry, my english is very basic, but I will try tell you my experience.

I developed Basic for many years, in Excel, and Calc. I writed a book (in spanish) of more 500 pages for develop macros in OpenOffice/Libre with Basic.

But... I knowed Python... and all changed. I thing, Python is better than Basic in all; it learn easyly, extensive core, libraries of third, very good documentation, and the most important, a great comunity.

If you want learn ans use Basic, not problem, but where Basic end, Python just beginning

Best regards

There is a book from the early/mid eighties, that is simply lists the
vocabulary of the various dialects of BASIC in use then. IIRC, it was
called _The BASIC Book_. It was written specifically for programmers to
port software between the various systems that were available.

Back then, all variants of basic used line numbers, and allowed GoTo.
Today, several variants of BASIC don't use line number, and some
variants don't have GoTo.

jonathon

GoTo. One of the curses of Basic, the GoTo.

When used by newcomers (and a few some old hands too) a
Basic program would  soon become an unstructured mess of
GoTo's and a hassle to debug.  One of our Pascal lecturers was
very  anti-Basic and forbade us to use it,  or to even talk about it
in his presence.

Thank you Tom and Jonathon for the memory,
Gordon.

Hi :slight_smile:
@ Mauricio: Wow!!! That was very eloquent! :)) Thanks :slight_smile:

@ Gordon: Sorry! I had a go with Pascal but got distracted and didn't get
very far. It looked a LOT more elegant but i was entrenched in using Basic
at the time and couldn't handle the back to basics at that point in time.

@ all: Do you think Python is easy as a 1st language? - or is it better to
start with something else first to ease into it all?

I'm kinda playing around with Scratch a bit and kinda learning Python but
at a very relaxed pace. Both seem quite good fun now :slight_smile:

Regards from a Tom :slight_smile:

Python is great. Quite easy to get into, but capable enough that you can really get stuff done.

GoTo. One of the curses of Basic, the GoTo.

There is a Python implementation that includes GoTo!

One of our Pascal lecturers was very  anti-Basic and forbade us to use it,  or to even talk about it

My Pascal instructor was of the mind that the only two control
structures needed were:
* GoTo;
* Repeat Until;

That makes for some very messy code.

jonathon

GoTo. One of the curses of Basic, the GoTo.

There is a Python implementation that includes GoTo!

One of our Pascal lecturers was very  anti-Basic and forbade us to use it,  or to even talk about it

My Pascal instructor was of the mind that the only two control
structures needed were:
* GoTo;
* Repeat Until;

That makes for some very messy code.

jonathon

I think there is a problem with python: nomadism ! If I want to use my USB key with Base connecting to HSQLDB I need to install LibreOffice/OpenOffice into the PC, then JAVA, Then HSQLDB ... then Python ! It's a lot. I would like to use nn install system at work because admin installed LibreOffice and Java but not Python ... So may be for me java would be better than python in this context. What I love with Basic programmation : all it's embeded with my Base application !

*** Do you know a good book for LibreOffice/OpenOffice/UNO Java/Python programmation ? ***
What about UNO API if I use Python/Java ? Is there inline documentation ?

What about events management if I'm using event catch into extern application ? With basic I can open a simple dialog box to connect events to catch function, but with extern program I will need to register manualy. The interest to use LibreOffice Base is to build rapidedly a simple database interface...

I know, if you use Python or Java you are connected with Uno. But I know also there is some complexity with typing variables between Uno or Java/Python scripts ... And then, I know also Python is using some C++ interfaces,by memory for event mangement .... Uno is C++ also, isn't it ?

Disclaimer: I have only used Python once to to talk to LO. In fact, I work pretty hard to write all of my "macros" in Basic because support is very consistent across platforms. I cannot comment directly on Python, but, in Basic, I do not need to worry about which interface handles which calls, that level of detail is handled for free.

If I decided to not use Basic, I would evaluate which other language has the best integration, and, I cannot comment on that since I rarely leave Basic. I looked at Python because there was an issue with the Python version for a macro that someone wrote and they were having trouble with integration.

My Primary complaint about Python is that the block structure is directly related to the spacing and I have had that messed with as I moved between machines and operating system. I do not expect that to be a problem if you do not move between machines and if you have full control over the editor that use in terms of how it is configured....... And if you are not pasting code that others have written or from web sites. All of those issues have caused me issues all related to how Python interprets blocks. When I write code in my Python specific editor and I stay on one machine, and I do not integrate code from other places, I have no problems with it. I should note that I work with some people who feel that they must solve every problem with Python.

As for your first language, I do not see a problem with using Python, but I also do not see a problem using Basic. Much depends on your end goal. Especially if you limit external dependencies, Python should run unchanged on most machines with a few caveats.

Why do you want to program? More specifically, what do you want to produce?

What type of programs do you want to write? (GUI, command line, control LO, etc...)

How portable must your code be?

If you want to write a GUI and it will only run on Windows, I think that Visual Studio has a decent environment for development. I spend way more time writing Java and C++ these days, which means that I have not been using Visual Studio lately.

All languages have pros and contra, but the advantages of Python are very big more than it you disadvantageous.

For example, the indentation in code, that have effect in the execution, for some users it's a problem, for me it's a virtue. The majority modern IDEs, help you with this.

Basic, maybe it's perfect for you, depend what you needed.

But, Python is so much funny... :slight_smile:

You can make; macros, functions of Calc (full integrated in function wizard), extensions and new UNO components.

With some precautions, Python is perfectly portable. Is possible insert code Python into documents ODF.

The short curve for learn Python, it's more short with our help. If you or others are interested, we can continuity the wiki document for Python macros. [1]

Best regards

[1]https://wiki.documentfoundation.org/Macros/Python_Guide

This last part is very important for more serious programs. For certain serious integration, Basic fails, but it sounds like Python would be suitable. Of course, if you are asking what language to learn, you are not likely to write something so difficult, but, the fact that you can do it makes it easier.