Bug 147457

Summary: Basic 'Me' keyword not implemented
Product: LibreOffice Reporter: Alain Romedenne <alain.romedenne>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: enhancement CC: himajin100000, rafael.palma.lima
Priority: medium    
Version: Inherited From OOo   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108908, 127592, 114263    
Attachments: 'Me' Basic keyword example of use

Description Alain Romedenne 2022-02-16 10:04:52 UTC
Description:
When scripting ClassModule Basic modules, one cannot use 'Me.' prefix in order to refer to ClassModule object current instance.

Steps to Reproduce:
A 'Me' keyword macro example is available in the attached file.

Actual Results:
'Me' is not supported as a keyword in Basic ClassModules.

Expected Results:
A background implicit assignment of 'Me' object instance variable should occur when instantiating 'New' objects with Basic.

New operator:
https://help.libreoffice.org/latest/en-US/text/sbasic/shared/new_keyword.html?DbPAR=BASIC#bm_id3149205

Let/Set statements:
https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03103700.html?DbPAR=BASIC



Reproducible: Always


User Profile Reset: No



Additional Info:
This should be supported when using 'Option Compatible' or 'Option VBASupport 1' Basic compiler options.

VBA 'Me' keyword:
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/me-keyword

Note: It is possible to circumvent 'Me' lack of support, but this requires to hack around LibreOffice Basic. See the attached file for an example of such hack.
Comment 1 Alain Romedenne 2022-02-16 10:08:27 UTC
Created attachment 178301 [details]
'Me' Basic keyword example of use
Comment 2 Rafael Lima 2022-09-16 18:42:20 UTC
Since this is a feature of class modules, the keyword "Me" should also be implemented with Option Compatible / VBASupport 1.

I am setting this to NEW.
Comment 3 Justin L 2022-10-05 13:48:16 UTC
Just noting that there is a "Me" in basic/source/runtime/stdobj.cxx. It must not do what OP wants, since it has been there ~forever.
Comment 4 Rafael Lima 2022-10-10 20:19:15 UTC
(In reply to Justin L from comment #3)
> Just noting that there is a "Me" in basic/source/runtime/stdobj.cxx. It must
> not do what OP wants, since it has been there ~forever.

Indeed it exists in the code:

https://opengrok.libreoffice.org/xref/core/basic/source/runtime/methods1.cxx?r=6b3e66cd#2926

But for some reason, using Me in a class module results in the error "BASIC runtime error. Variable not defined."