Do Public/Private variables lose their value between event handlers in Base macros?

Hello,
I’m testing LibreOffice Base macros and noticed that Public and Private module-level variables do not keep their value between two button clicks. They are always reset to 0. Only a Global variable survives between event handlers.
This happens even in a minimal test: one form, one module, one public variable, one private variable, one global variable. After setting the values in one button click, only the global variable is still set when another button handler runs.
My questions:
1. Is this normal or expected in LibreOffice Basic?
2. Am I declaring or using these variables incorrectly?
3. If Public/Private lose their values after each macro finishes, what are they intended to be used for?
Thanks for any clarification.
John

There are 4 different types of variables:
Have a look here: Using Procedures, Functions or Properties, special “Declaring Variables Outside a Sub a Function or a Property”.

I’m only using DIM and GLOBAL.

  • DIM inside a procedure and (as parameter) from procedure to procedure. Will be set new for every new start of the procedure.
  • GLOBAL for saving values I need for a another event also. This will be the only variable, which saved it’s value for more than starting an ending a macro. So it’s the only which will work if you will get a variable by a click on one button and work with this variable with another button.

Difference between PRIVATE, DIM and PUBLIC might be it will work only inside of one module (PRIVATE) or the whole library (PUBLIC). Have read DIM runs different on Linux and Windows. On Linux like PRIVATE, on Windows like PUBLIC.

See also here.

#hd_id3154186