Issue 52057 - starbasic:Global of userdefined type gets lost
Summary: starbasic:Global of userdefined type gets lost
Status: ACCEPTED
Alias: None
Product: General
Classification: Code
Component: scripting (show other issues)
Version: OOo 1.0.0
Hardware: PC Windows, all
: P3 Trivial with 2 votes (vote)
Target Milestone: AOO Later
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-16 10:39 UTC by villeroy
Modified: 2017-05-20 10:44 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description villeroy 2005-07-16 10:39:27 UTC
The workaround is: save in in an array.
<<<<<<<<<<<<<<<<BASIC>>>>>>>>>>>>>>>>>>
Option Explicit
Type myObj2
  Document
  EventListener
End Type

Global aObj(0)
Global oMyObj as myObj2

' Run this routine several times
Sub Main()
Main2()
Main3()
End Sub

Sub Main2
if isEmpty(oMyObj) then oMyObj = createObject("myObj2")
if IsEmpty(oMyObj.Document) then
  MsgBox("oMyObj.Document was Empty")
  oMyObj.Document = 10
  MsgBox("oMyObj.Document now " &   oMyObj.Document)
else
  MsgBox("oMyObj.Document was " & oMyObj.Document)
  oMyObj.Document = oMyObj.Document +5
end if
End Sub

Sub Main3
if isEmpty(aObj(0)) then aObj(0) = createObject("myObj2")
if IsEmpty(aObj(0).Document) then
  MsgBox("aObj(0).Document was Empty")
  aObj(0).Document = 10
  MsgBox("aObj(0).Document now " &   aObj(0).Document)
else
  MsgBox("aObj(0).Document was " & aObj(0).Document)
  aObj(0).Document = aObj(0).Document +5
end if
End Sub
<<<<<<<<<<<<<<<<<END BASIC>>>>>>>>>>>>>>>>>>>>>>>>>>>
Comment 1 noel.power 2005-09-02 08:47:26 UTC
reassign to ab
Comment 2 ab 2005-09-06 07:31:16 UTC
Started
Comment 3 ab 2005-09-06 07:32:10 UTC
OS: Linux -> Windows,all as this is no Linux specific problem.
Comment 4 bmarcelly 2015-03-07 09:41:58 UTC
Simpler workaround:
  Global oMyObj As Variant
and initialize at runtime, as in your code.

Same bug and solution with a Uno structure
  Global aDate As New com.sun.star.util.Date
replace with :

Global aDate As Object

Sub initalize
  aDate = New com.sun.star.util.Date
  aDate.Year  = 2015
 ....
End Sub
Comment 5 Marcus 2017-05-20 10:44:13 UTC
Reset the assignee to the default "issues@openoffice.apache.org".