Generating bad code

Posted by jmls on 18-Mar-2011 03:17

No, not me

10.2B SP03

Trying to use a DevExpress treeview, added some nodes using the node editor, and the OEA generates the following code

DEFINE VARIABLE arrayvar1 AS "System.Object[]" EXTENT 3 NO-UNDO.

    arrayvar1[1] = "foo".

    arrayvar1[2] = ?.

    arrayvar1[3] = ?.

Trouble is, the code does not compile

Error is 14830

You cannot assign a scalar value into a .NET array object. (14830)

Though in the ABL you can assign a scalar value into an array (it gets set into each element), it is invalid to assign a scalar value into a .NET array object.

Bug, I presume. Any workarounds ?

All Replies

Posted by Admin on 18-Mar-2011 03:21

No, not me

 

Any workarounds ?

Use an ABL Array instead:

DEFINE VARIABLE arrayvar1 AS "System.Object" EXTENT 3 NO-UNDO.

arrayvar1[1] = "foo".

arrayvar1[2] = ?.

arrayvar1[3] = ?.

Posted by jmls on 18-Mar-2011 03:36

err, it's not me - it's the OEA generating the code in the InitializeComponent section

Posted by Admin on 18-Mar-2011 03:41

Does the Control/Component in question expect a two-dimensional array? When that's VD generated code, I'd log it with TS.

Posted by Matt Baker on 18-Mar-2011 13:59

DevExpress code generator is expecting to generate a two-dimensional array with the first entries of the array assigned to scalars.  Which to me doesn't sound right.  This is either OEA throwing away something really important when trying to write the ABL code equivalent syntax, or devexpress generating bogus code dom structure.

If it were one dimensional it would look like this which is valid.

DEFINE VARIABLE arrayvar1 AS "System.Object" EXTENT 3 NO-UNDO.
    arrayvar1[1] = "foo".
    arrayvar1[2] = ?.
    arrayvar1[3] = ?.
   

The ABL error message is correct based on the syntax.

Posted by jmls on 18-Mar-2011 14:16

It's simple to reproduce.

Add the treeview. Run the node designer. Save.

Posted by bdearborn on 18-Mar-2011 14:21

Hi,

I am currently out of the office on and will be returning to the

office on March 23, 2011. I will be checking email but If you need

immediate assistance please call my cell phone at 503-805-8598 or

contact Jim Stein at jstein@cornerstar.com.

Thanks,

Bryn Dearborn

503-805-8598

--

Bryn Dearborn

503-928-8115 (Work)

503-805-8598 (Cell)

Cornerstar

Posted by Admin on 19-Mar-2011 02:07

The ABL error message is correct based on the syntax.

Good for the compiler developers, but it won't change the situation for the customer :-)

So when the control behaves well in the Visual Studio, I guess it's still an OpenEdge (Architect) issue. Probably it stumbles because the ABL has no built in support for two-dimensional arrays. I guess in this case the generated code should generate a .NET Array instead of an ABL array or even a combination of .NET and ABL array (which "System.Object[]" EXTENT would be).

This thread is closed