Issue 67776 - OOoBasic: Add compatibility Warning on Handling Variant Arrays
Summary: OOoBasic: Add compatibility Warning on Handling Variant Arrays
Status: CONFIRMED
Alias: None
Product: documentation
Classification: Unclassified
Component: Manuals (show other issues)
Version: OOo 2.0.4
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on: 68883
Blocks:
  Show dependency tree
 
Reported: 2006-07-26 04:03 UTC by terrye
Modified: 2013-07-30 02:23 UTC (History)
6 users (show)

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


Attachments
Terry's doc (33.49 KB, application/vnd.oasis.opendocument.text)
2006-07-26 13:42 UTC, grsingleton
no flags Details
Vba2OOo examples (86.49 KB, application/octet-stream)
2006-07-26 13:44 UTC, grsingleton
no flags Details
Original Cross reference (267.50 KB, application/vnd.sun.xml.writer)
2006-07-26 13:45 UTC, grsingleton
no flags Details
VBA to OOo Basic Comparison Strawman draft V0.F (543.54 KB, application/vnd.sun.xml.writer)
2006-08-02 05:08 UTC, terrye
no flags Details
ab02vba Announcement (24.48 KB, application/vnd.sun.xml.writer)
2006-08-04 15:21 UTC, terrye
no flags Details
zipfile of master and chapters. (418.41 KB, application/octet-stream)
2006-08-07 23:22 UTC, grsingleton
no flags Details
Converter for Calc (354.13 KB, application/octet-stream)
2006-08-22 12:52 UTC, grsingleton
no flags Details
VB Converter for Writer (397.24 KB, application/octet-stream)
2006-08-22 12:53 UTC, grsingleton
no flags Details
Chapter 10 from user guide. (33.94 KB, application/vnd.oasis.opendocument.text)
2006-09-04 01:27 UTC, grsingleton
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description terrye 2006-07-26 04:03:27 UTC
The following code fragments compare VBA and OOo Basic handling of Variant Array
structures.  Essentially OOB does these by Reference and VBA by value.  This is
sufficiently different to badly burn an experienced VBA programmer.  

It is unrealistic at this stage to change the OOB behaviour here, but at least
the manual should include a clear VBA compatibility warning on this behaviour. 
You may also wish to warn about some of the other consequences E.g. the variant
(ndx1) (ndx1) syntax does not work.

============= OOB Test Code =============

Dim vAa(2), vAb(2), vA2a(2, 2), vLa, vLb, a, b, x, y, sht As Object
Set sht = ThisComponent.Sheets(0)

     a = CLng(3)
     vAa(1) = a       ' vAa = *,3,*  where * denotes Empty
     vA2a(1, 2) = 5.1 ' vA2a = [[*,*,*],[*,*,*],[*,*,*]]
 Set vA2a(2, 1) = sht ' You can also assign objects with a set
     b = vA2a(2, 1).Name ' And access them in the intuative manner
     vLa = Array(1, "a", CDbl(3.4))
     vLb = Array(1, "a", CDbl(3.4), 23)
     vAa = vLa        ' CAN assign to list to array
     vAb = vLb        ' CAN assign to list to array of different length
     				  ' which will redim the Array 
     vAb = vAa        ' CAN assign to array to array
     vAb()= vAa()     ' Brackets don't make any difference either
     vLa = vAa        ' CAN assign to array to list
'#CE vLb = vA2a(1)    ' But not array slices to lists
     vAa(2) = "x"     ' vAa now = 1,"a","x"
                      ' but as is vAa now
                      ' So Array to List assignent by REFERENCE
     vLb = vLa        ' CAN assign to list to list
     vLa(2) = "Y"     ' vLa now = 1,"a","Y"
                      ' as is vBa now
                      ' So List to List assignent by REFERENCE
     vLb(2) = vLa     ' and a list to a list elelment  so
                      ' vLB now = 1,"a",(1,"a","Y")
'#CONFUSING           ' Compiles and runs but is misleading
     a = vLb(2, 2)    ' The second index is ignored 
                      ' so this is the same as 
     a = vLb(2)       ' which five the third element of vLa (1,"a","Y")           
'#CE a = vLb(2)(2)    ' LoL notation FAILS in Compile
x=vLb(2) : a = x(2)   ' but deferencing works fine as this is by REFERENCE
     vLa = vA2a       ' Multi dimensional Array to list
     a = vLa(1, 2)    ' Array notation works fine. a = 5.1
'#CE a = vLb(2)(2)    ' LoL gives subscript out of range error
     vLb(0) = vA2a    ' Even Multi Array to list element
'#CE a = vLb(0)(1, 2) ' again LoL format pukes in compile but
 a = x(1, 2)' deferencing works as expected = 5.1

' All of this has been by REFERENCE (i.e. clone of all vectors)
'#CE     vLb(0)(1, 2) = 4.5
     a = vA2a(1, 2)   ' Still 5.1
' Including objects are still objects (that is refences which are therefore cloned)
x=vLb(0) : x(2, 1).Name = "Fred"
sht.Name = b          ' But let's put it back for tidiness
' only scalar variant assignment are by Value
b = 1
a = b
b = 2
'Yet this does mean that you can create all sorts of list structures
a=Array(1,2,3,4)
a(3) = a    ' look at this one in the IDE watch window
a(3) = nothing

============= VBA Test Code =============

     a = CLng(3)
     vAa(1) = a       ' vAa = *,3,*  where * denotes Empty
     vA2a(1, 2) = 5.1 ' vA2a = [[*,*,*],[*,*,*],[*,*,*]]
 Set vA2a(2, 1) = sht ' You can also assign objects with a set
     b = vA2a(2, 1).Name ' And access them in the intuative manner
     vLa = Array(1, "a", CDbl(3.4))
'CE# vAa = vLa        ' Can't assign to list to array
'CE# vAb = vAa        ' Can't assign to array to array
'CE# vAb()= vAa()     ' Brackets don't make any difference either
     vLa = vAa        ' CAN assign to array to list
'#CE vLb = vA2a(1)    ' But not array slices to lists
     vAa(2) = "x"     ' vAa now = *,3,"x"
                      ' but vLa still = Empty,3,Empty
                      ' So Array to List assignent by VALUE
     vLb = vLa        ' CAN assign to list to list
     vLa(2) = "x"     ' vLa now = *,3,"x"
                      ' but vBa still = Empty,3,Empty
                      ' So List to List assignent by VALUE
     vLb(2) = vLa     ' and a list to a list elelment  so
                      ' vLB now = *,3,(*,3,"x")
'#RE a = vLb(2, 2)    ' subscript out of range error
     a = vLb(2)(2)    ' but LoL notation works fine. a ="x"
     vLa = vA2a       ' Multi dimensional Array to list
     a = vLa(1, 2)    ' Array notation works fine. a = 5.1
     a = vLb(2)(2)    ' LoL gives subscript out of range error
     vLb(0) = vA2a    ' Even Multi Array to list element
     a = vLb(0)(1, 2) ' works as expected = 5.1
     
' All of this has been by value (i.e. copy of all vectors)
     vLb(0)(1, 2) = 4.5
     a = vA2a(1, 2)   ' Still 5.1
' Except objects are still objects (that is refences which are therefore cloned)
 vLb(0)(2, 1).Name = "Fred"
sht.Name = b          ' But let's put it back for tidiness
Comment 1 grsingleton 2006-07-26 13:42:17 UTC
Created attachment 38046 [details]
Terry's doc
Comment 2 grsingleton 2006-07-26 13:43:10 UTC
Putting all relavent docs in one place.
Comment 3 grsingleton 2006-07-26 13:44:25 UTC
Created attachment 38049 [details]
Vba2OOo examples
Comment 4 grsingleton 2006-07-26 13:45:14 UTC
Created attachment 38050 [details]
Original Cross reference
Comment 5 grsingleton 2006-07-26 13:48:02 UTC
All people involved with a Cross reference are now on this issue. I have changed
it to task so it can be worked on.
Comment 6 terrye 2006-08-02 04:58:43 UTC
I've finished the next cut of the material.  A lot more content, but need to
discuss with Gerry.  See V0.F as posted.
Comment 7 terrye 2006-08-02 05:08:07 UTC
Created attachment 38191 [details]
VBA to OOo Basic Comparison Strawman draft V0.F
Comment 8 grsingleton 2006-08-02 23:23:58 UTC
Assigned to myself. Will re-assign to TerryE as needed.
Comment 9 terrye 2006-08-04 15:20:06 UTC
I have uploaded a copy of announcement ab02VBA in reabable format for background
reference
Comment 10 terrye 2006-08-04 15:21:39 UTC
Created attachment 38263 [details]
ab02vba Announcement
Comment 11 grsingleton 2006-08-04 16:00:11 UTC
Very useful. I am in the process of creating a Master doc and chapters.
Comment 12 grsingleton 2006-08-07 23:21:30 UTC
Master doc and chapters attached in a zipfile. Unpack into a suitable directory.
In case there are problems I am using m180 
Comment 13 grsingleton 2006-08-07 23:22:36 UTC
Created attachment 38325 [details]
zipfile of master and chapters.
Comment 14 grsingleton 2006-08-20 21:33:05 UTC
We have a member whois VBA and Calc aware who is willing to take on the rewrite.
His name is Walter. 

Walter, the master and chapters are in the zip. Terry's latest analysis et
cetera is 
OOoBasicVBAcomparisonV0.F.odt

Please post any questions to this issue rather than the list.
Comment 15 grsingleton 2006-08-22 12:51:34 UTC
Added conversion tools for Windows OOo. I expect that these are in French.
Comment 16 grsingleton 2006-08-22 12:52:50 UTC
Created attachment 38697 [details]
Converter for Calc
Comment 17 grsingleton 2006-08-22 12:53:27 UTC
Created attachment 38698 [details]
VB Converter for Writer
Comment 18 terrye 2006-08-22 14:08:54 UTC
Gerry, I've had a look at the two converter.  They answer a Q, but just the
wrong Q.  What they do is to provide a COM object which maps a subset of the
Excel object model onto the Calc engine.  What this means is that if you have a
VB6 or VBscript App that is external to but talks to Excel then you can move the
backend to Calc IF you stick to the API subset that this maps.

What it doesn't do is to convert embedded VBA in Excel into embedded OOo Basic
in Calc.  Now you could use the automation bridge to bind to this com object
from OOo Basic, but in this case you'd be converting the current in-process
Basic-UNO dialogue to an out of process one via these converters.  I'll do some
timings to validate, but I really don't think that this is the way to go.
//Terry
Comment 19 terrye 2006-08-22 14:09:09 UTC
Gerry, I've had a look at the two converter.  They answer a Q, but just the
wrong Q.  What they do is to provide a COM object which maps a subset of the
Excel object model onto the Calc engine.  What this means is that if you have a
VB6 or VBscript App that is external to but talks to Excel then you can move the
backend to Calc IF you stick to the API subset that this maps.

What it doesn't do is to convert embedded VBA in Excel into embedded OOo Basic
in Calc.  Now you could use the automation bridge to bind to this com object
from OOo Basic, but in this case you'd be converting the current in-process
Basic-UNO dialogue to an out of process one via these converters.  I'll do some
timings to validate, but I really don't think that this is the way to go.
//Terry
Comment 20 grsingleton 2006-08-22 15:16:38 UTC
Thanks for the analysis. This means I no longer need to pursue the author. Oh
well, what can one expect.  
Comment 21 terrye 2006-08-22 19:21:01 UTC
No Gerry, your confusion is perfectly understandable here.  We have lots of 
rings and changes going on, and it will also get confusing for the general 
developer as well.  I'll discuss this with Walter when he's up to speed.  We 
probably could do with a clear diagram in the intro showing the options and 
pro's and con's so that the reader knows what is what.  I also saw a post on 
this in the OOoF and I will chip in on this.  //Terry 
Comment 22 wamarch 2006-09-03 23:17:07 UTC
copied from an email from Terry to WalterAM, the proposed structure of the final:
Overview and Introduction sections.
Part I — User Guide
 Examples of Porting Visual Basic for Applications to OOo Basic.
 Introduction to the Integrated Development Environment (IDE)
 Porting Sample Workbook [Spreadsheet]
Part II — Reference
 The Major Architectural Differences Between VBA and OOB
 Syntax and Semantic Differences
 Using the UNO Object Model for Calc Documents
Part III — Appendices
 (Appendix A:  XRay tool) refer the reader to the author’s howto on web site.
 Appendix B: Supporting Functions 
 Appendix C:  Multi-Page Control
Bibliography
PDL

I can find the other parts, but I am not sure where to find Introduction to the
Integrated Development Environment (IDE). There is Using the OOB IDE from
Terry's doc but there is no text in the copy I have and there is  Integrated
Development Environment (IDE) Differences from James doc.
WalterAM
Comment 23 grsingleton 2006-09-04 01:25:19 UTC
Re-assigning to walteram since he is looking after things.
Attached the Basic chapter from the user guide to get you started. This chapter
is super basic so do not be surprized.
Comment 24 grsingleton 2006-09-04 01:27:46 UTC
Created attachment 38920 [details]
Chapter 10 from user guide.
Comment 25 wamarch 2006-09-09 13:32:41 UTC
With Terry on vacation until the 25th of September, I am going to keep looking
over what already exists and I think I've got two subprojects I want to work on:
see if I can develop an order for Syntax and Semantic Differences table
develop an IDE differences section from existing docs

WalterAM
Comment 26 grsingleton 2006-10-30 15:09:43 UTC
Updated version and Summary to better reflect our goal.
Comment 27 Rob Weir 2013-07-30 02:23:52 UTC
Reset assignee on issues not touched by assignee in more than 2000 days.