Returning 2D Arrays from a method bug?

I remember at one time in RB one could not return multi-dimentional but I thought that changed…
I am pretty sure I have returned 2D arrays from a method at some point in the past… but I could be wrong… So is it it supported and if so should it be defind like this?

Function Test() As Picture(,) 'some code End Function

If not how should it be defined?

Or has a bug crept in at some point?

When I put the above on the default window I get the error:

Window.Name This type conversion may only be implemented for one dimentional arrays

The error message is obviously a bug as the error (if there is one) should me on the Method “test”, not the Window. Also I don’t know what type conversion it is taking about…

You can’t return 2D arrays of Object type from Windows or Classes. They do work from Modules though. My <https://xojo.com/issue/26312> has been closed as not reproducible long ago. Not sure why they couldn’t see it.

I opened a new case:

<https://xojo.com/issue/38075>

And included a trivial project… I found the bug on a class i created but the test app puts it on a Window…

You said it works on a module so I thought if I converted to a shared method it would work, but it does not!!!

A significant bug IMO!!!

  • Karen

You can. Use Variant as the return type.

Defeats type safety and adds more overhead. The real workaround is to pass the array into the method and have teh method modify it.

In 2014r3.2 seems to work fine with a 2 D array of integers
New Project
Window1 Open event

[code]Sub Open()
dim a(-1,-1) as integer

a = untitled()

break
End Sub
[/code]

Window1.Untitled method

[code]Function Untitled() As integer(,)
dim tmp(1,1) as integer

tmp(0,0) = 1
tmp(0,1) = 2
tmp(1,0) = 3
tmp(1,1) = 4

return tmp
End Function
[/code]

However with an array of Pictures it gives the message “this type conversion is only implemented for one-dimensional arrays”
So it seems to only be 2d arrays of object that have this issue

Thanks for pinning this down. For now I’ll wok around it

  • Karen

Yeah its curious as from what I can see just the method existing on the window is all it takes.
You never have to call it - it just has to exist.

And it does seem to only be a 2d array of object types - I’ve not seen if there are any that do work - that would be really odd if Pictures don’t but Dates do.

Yes, simply defining the method triggers the error…

  1. New desktop project
  2. Add this method to Window1

Sub Untitled() As Object(,) End Sub

  1. Analyze project -> error “Window1.Name” - This type conversion is only…

Notice it mentions “Window1.Name” as the source of the error, not the methods name. ??

Happens for Object type arrays of any dimension above 1.

error happens in: Class, Window, ContainerControl
no error in: Module, Interface (but the interface can’t be implemented!)

Same behavior when using a Delegate type instead of Object. But multidimensional arrays of Enumeration and Structure types work without error.

[quote=165567:@Will Shank]Yes, simply defining the method triggers the error…

  1. New desktop project
  2. Add this method to Window1

Sub Untitled() As Object(,) End Sub

  1. Analyze project -> error “Window1.Name” - This type conversion is only…

Notice it mentions “Window1.Name” as the source of the error, not the methods name. ??[[/quote]
Thats really an issue with not being able to show you the internal code for a Window

Enums ar basically integers so not surprising
Structures aren’t objects so they’re more like integer etc

Definitely odd

It’s a bug in the compiler. The IDE is showing the location as Window1.Name because the compiler is basically saying there’s an error on the first line of the Window1 class.