Page 1 of 1

Excel and Quad WX of 3

Posted: Sun Jan 01, 2017 6:52 pm
by paulmansour
Happy New Year All.

I have a bunch of code that drives Excel, written back before ⎕WX 3. To keep it running I have ⎕wx←1.

I would like to get it to run under ⎕wx←3.

I have the following line of code that that returns a range object by specifying the upper left and bottom right cell addresses of the block of cells, (which then I can set or get the Value2 property):

      ws.Range ws.Cells.Item¨(2 3) (4 6)


I cannot seem to alter this to get it to run under WX 3. I understand that indexers and the item property are now different, but I don't get far. I clearly don't understand, at a minimum, how the cells collection is working.

Can someone give me a little insight here?

Is there documentation that I missed? I read the chapter on OLE, and it discusses some basic stuff with respect to changing from WX 1 to WX 3, but it did not help me rewrite the above line.

Thanks.

Re: Excel and Quad WX of 3

Posted: Sun Jan 01, 2017 8:07 pm
by Morten|Dyalog
Hi Paul, Happy New Year!

With ⎕WX=3, Range and Cells[.Item] become index-able properties rather than methods. Both collections allows you to index them as if it were 2-dimensional, but the two "indices" that you pass are actually passed as arguments to an underlying get_Range / get_Item "indexer" method:

Code: Select all

      ⍴ws.Range[ws.Cells[1;1];ws.Cells[3;2]].Value2
3 2
      ⍴ws.Range[⊂'B3:D6'].Value2 ⍝ ALternative form
4 3


Hope this helps! I am not sure there was any documentation that explained exactly how this works.

Re: Excel and Quad WX of 3

Posted: Tue Jan 03, 2017 10:00 am
by Vince|Dyalog
Hi Paul and Morten,

Happy New Year!

It was only mentioned in our 11.0 release notes.

Previously, I have taken the text from our 11.0 release notes and posted it here:

"Why does COM code written for a pre-11 Dyalog stop working?"
http://www.dyalog.com/forum/viewtopic.php?f=22&t=179

Regards,

Vince

Re: Excel and Quad WX of 3

Posted: Tue Jan 03, 2017 1:48 pm
by paulmansour
Morten,

Thanks!!! That works.

By the way, in both WX 1 and 3, when you get a range for a single cell, if that cell is null, then there is no Value2 property. You can assign it, but you can't reference it. Is that a bug in Dyalog or an unavoidable feature of Excel?

Thanks again!

Paul

Re: Excel and Quad WX of 3

Posted: Wed Jan 04, 2017 10:51 am
by Morten|Dyalog
It's a design decision: Our original thinking was that VALUE ERROR was the closest APL equivalent to a NULL, but that has proved to be impractical in many circumstances. 2041 I-Beam provides a work-around and allows you to specify what to return in place of NULL or ERROR:

http://help.dyalog.com/15.0/Content/Language/Primitive%20Operators/Override%20COM%20Default%20Value.htm