Bug 134504 - Editing Base Public and Private variables not working
Summary: Editing Base Public and Private variables not working
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.4.4.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-04 16:07 UTC by tj_trevor.jones
Modified: 2022-11-05 13:40 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Form with 2 buttons (10.74 KB, application/vnd.oasis.opendocument.database)
2020-07-20 18:30 UTC, tj_trevor.jones
Details
the document that works expectedly (10.72 KB, application/vnd.oasis.opendocument.text)
2020-07-20 18:42 UTC, himajin100000
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tj_trevor.jones 2020-07-04 16:07:39 UTC
Description:
No value can be assigned to a variable defined as public or private.

Steps to Reproduce:
1.Create a form with 2 Buttons
2.Define the following macros

OPTION EXPLICIT

Public  VarI AS Integer
Private VarS AS String

Sub Button1

MsgBox VarI
MsgBox VarS

VarI = 1
VarS = "One"

End Sub

Sub Button2

MsgBox VarI
MsgBox VarS

VarI = 2
VarS = "Two"

End Sub

3. Assign Each macro to the execute action of the appropriate button
4. Run the form and click each button alternately.

Actual Results:
MsgBox for VarI always displays 0
MsgBox for VarS always displays blank.


Expected Results:
MsgBox for VarI should alternately display 1 then 2
MsgBox for VarS should alternately display "One" then "Two"



Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.4.4.2
Build ID: 1:6.4.4~rc2-0ubuntu0.18.04.1
CPU threads: 3; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: en-GB (en_GB.UTF-8); UI-Language: en-US
Calc: threaded

This release was supplied by The Document Foundation, Debian and Ubuntu.
Copyright © 2000–2020 LibreOffice contributors.
LibreOffice was based on OpenOffice.org.
Comment 1 himajin100000 2020-07-19 11:24:20 UTC
1. What happens if you declare the variables VarI and VarS as "Global" instead of "Public" or "Private"
2. What happens if you add "Option VBASupport 1" to the code and keep the variables "Public" and "Private"?

I believe that variables declared with "Public" and "Private" under "Option VBASupport 0"(default) are not PersistentGlobal

https://opengrok.libreoffice.org/xref/core/basic/source/comp/dim.cxx?r=5f19287a#215

https://opengrok.libreoffice.org/xref/core/basic/source/comp/dim.cxx?r=5f19287a#220
Comment 2 Xisco Faulí 2020-07-20 15:01:10 UTC
(In reply to himajin100000 from comment #1)
> 1. What happens if you declare the variables VarI and VarS as "Global"
> instead of "Public" or "Private"
> 2. What happens if you add "Option VBASupport 1" to the code and keep the
> variables "Public" and "Private"?
> 
> I believe that variables declared with "Public" and "Private" under "Option
> VBASupport 0"(default) are not PersistentGlobal
> 
> https://opengrok.libreoffice.org/xref/core/basic/source/comp/dim.
> cxx?r=5f19287a#215
> 
> https://opengrok.libreoffice.org/xref/core/basic/source/comp/dim.
> cxx?r=5f19287a#220

Putting to NEEDINFO until the reporter comes back with feedback
Comment 3 tj_trevor.jones 2020-07-20 18:25:39 UTC
With variables declared as Global it works fine. VarI displays 1 then 2. VarS displays "one" then "two".

With "Option VBASupport 1" declared and the variables "Public" and "Private" 0 and space are displayed as before.
Comment 4 tj_trevor.jones 2020-07-20 18:30:12 UTC
Created attachment 163333 [details]
Form with 2 buttons

OPTION EXPLICIT
Option VBASupport 1

Public  VarI AS Integer
Private VarS AS String

Sub Button1

MsgBox VarI
MsgBox VarS

VarI = 1
VarS = "One"

End Sub

Sub Button2

MsgBox VarI
MsgBox VarS


VarI = 2
VarS = "Two"

End Sub
Comment 5 himajin100000 2020-07-20 18:42:20 UTC
Created attachment 163334 [details]
the document that works expectedly
Comment 6 himajin100000 2020-07-20 18:45:27 UTC
Reproduced.

It seems Base Forms works differently than odt.

minor note: the document attached by the buttons in the reproters macro uses Application macro, not Document Macro.
Comment 7 himajin100000 2020-07-20 18:46:23 UTC
typo

minor note: the buttons in the document attached by the reproter uses Application macro, not Document Macro.
Comment 8 QA Administrators 2022-07-21 03:33:53 UTC Comment hidden (obsolete)
Comment 9 Alex Thurgood 2022-07-21 05:33:46 UTC
Bug still present in 

Version: 7.5.0.0.alpha0+ / LibreOffice Community
Build ID: 8b82a71013567e148166b514d0ce0f5905f5a3e3
CPU threads: 8; OS: Mac OS X 12.4; UI render: default; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded
Comment 10 Alex Thurgood 2022-07-21 05:50:10 UTC
(In reply to Alex Thurgood from comment #9)
> Bug still present in 
> 
> Version: 7.5.0.0.alpha0+ / LibreOffice Community
> Build ID: 8b82a71013567e148166b514d0ce0f5905f5a3e3
> CPU threads: 8; OS: Mac OS X 12.4; UI render: default; VCL: osx
> Locale: fr-FR (fr_FR.UTF-8); UI: en-US
> Calc: threaded

If I include

Option VBASupport 1

and leave the Private and Public declarations,
 
it behaves in a manner I don't understand.

- clicking on Button 1 a first time after opening the form reproduces the bug and displays 0 and an empty MsgBox;

- clicking on Button 2 a first time then displays the values "1" and "One" respectively;

- subsequently clicking on Button 1 again, i.e. a second time, displays "2" and "Two".