Issue 123669 - BASIC Variable Scopes
Summary: BASIC Variable Scopes
Status: UNCONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: vba (show other issues)
Version: 3.4.0
Hardware: All Windows 7
: P3 Normal
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-10 02:49 UTC by biagio
Modified: 2013-11-10 02:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description biagio 2013-11-10 02:49:16 UTC
two bugs ? , variable scope of BASIC

=================================================
1st
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Variable_Scopes
The Private command is used to declare variables that can only be used locally in a module. 

however,

From the tests I've done, the module-level variables are always visible from the outside of the module, whether  declared  public or private indifferently

es

' ModProvaScope
private m_private_str as string
public m_public_str as string

Public Sub ValorizzaModVars
m_private_str = " my_m_private_str "
m_public_str = " my_m_public_str "
end Sub


' ModProva
sub ProvaScope
call ValorizzaModVars
msgbox m_private_str ' " my_m_private_str "
msgbox m_public_str ' " my_m_public_str "
msgbox ModProvaScope.m_private_str ' " my_m_private_str "
msgbox ModProvaScope.m_public_str ' " my_m_public_str "
end Sub


==================================================
2nd
in oo BASIC is still possible to create a module-class
just write at the beginning of the module
option Compatible
option ClassModule

eg if the module is renamed ClsMyClass
by another module you can create the object with
set oMyClass = new ClsMyClass

the scope-bug is that the class is visible only to other modules in the same workbook

for example, if I define the module-class in the [Macros].Standard then this will no longer be visible from the inside of the modules of the worksheet current open files