OLE Dyalog 10.1 vs OLE Dyalog 13.0

Using (or providing) components based on the "Win32" framework

OLE Dyalog 10.1 vs OLE Dyalog 13.0

Postby Tranber44 on Tue Nov 13, 2012 8:15 am

Hello,

I passed under Windows 7 - 64 bits

With Dyalog 10.1 rel 1 in this environment the use OLE-Excel works normally.

'XL'⎕WC'OLEClient' 'Excel.Application' ⍝ Connection Excel - Espace XL
XL.Workbooks.Open(⊂∊PATHO,'\SuivBudg.xls')⍝Ouverture dossier Excel
WBudg←XL.Workbooks.Item 1 ⋄'XL'⎕WS'Visible' 1
WBudg.Sheets.(Item('Budg')).(Range('B1:B1')).Value2←#.IDET ⍝ Transfert données ligne entete



In the same configuration but with Unicode/32 Version: 13.0.8806.0 - Build ID: 21986312 - Serial Number: 500871, I am confronted with an error for which I do not find the solution

SYNTAX ERROR
VERBUDG2[29] WBudg.Sheets.(Item('Budg')).(Range('B1:B1')).Value2←#.IDET ⍝ Transfert données ligne entete

Why?

Kind regards

Bertrand Delassus
Tranber44
 
Posts: 34
Joined: Mon Jan 11, 2010 4:46 pm

Re: OLE Dyalog 10.1 vs OLE Dyalog 13.0

Postby Vince|Dyalog on Wed Nov 14, 2012 9:20 am

Hi Bertrand,

I believe that you're seeing a difference in behaviour from a different setting of a system variable called ⎕WX. It is now 3 by default.

It was introduced with version 11.0. I will paste below a page from our version 11.0 Release Notes about this system variable.

External Object Behaviour
Version 11.0 improves the behaviour of COM and .Net objects, but for backwards compatibility it is possible to select old or new behaviour using ⎕WX.

Old behaviour:

Character vectors supplied as arguments to external functions, which are defined as String parameters, are automatically enclosed for you. Similarly, string results are automatically disclosed.
Properties that take parameters, such as the Item Property in a Collection, are treated as methods.
APL provides lists of the Properties, Methods and Events provided by a GUI object by exposing additional properties named PropList, MethodList and EventList.
New behaviour

Character vectors supplied as arguments to external functions, which are defined as String parameters, must be enclosed. Strings are returned as enclosed character vectors.
Properties that take indices, such as the Item Property in a Collection, are honoured as Numbered or Keyed Properties and may be accessed by indexing.
PropList, MethodList and EventList are not exposed. Instead, the information is provided by ⎕NL ¯2,¯3 and ¯8 (but alphabetically sorted).
The actual behaviour of a COM or .Net object is now determined by its value of ⎕WX. If ⎕WX is 0 or 1, the old behaviour will apply. If ⎕WX is 3, the new behaviour will apply.

The behaviour of COM and .Net objects in existing applications will remain the same (because ⎕WX will be 0 or 1) but you may obtain the benefits of the new behaviour by setting ⎕WX to 3 at the appropriate level in your application. Then, everything below that (in the namespace hierarchy) will adopt the new behaviour.

Note that regardless of the value of ⎕WX, Version 11 will honour the Default Property of an external object thereby permitting the direct use of indexing on the object itself.

For example, if xl is an instance of the Excel.Application COM class, the following expression to obtain the contents of the first Sheet in the first Workbook will succeed, whatever the value of ⎕WX.

xl.Workbooks[1].Sheets[1].UsedRange.Value2
Note that it is the value of ⎕WX which the object acquired when it was created, rather than the current value of ⎕WX, which decide the behaviour.

Like other system variables, ⎕WX is inherited from the environment when a new namespace, class or instance is created. Classes inherit the value of ⎕WX when a class is edited or fixed, unless the class script explicitly sets a value for ⎕WX. In the case of .NET classes, ⎕WX is inherited when the class or namespace is loaded from a .NET assembly. For built-in (GUI) classes, each new instance inherits ⎕WX when it is created.

Examples
      ⎕WX←1
'XLW' ⎕WC 'OleClient' 'Excel.Application'
XLW.Workbooks.Add ⍬
XLW.ActiveWorkbook.Sheets.(Item 'Sheet2').Index
2

⎕WX←3
XL←⎕WC 'OleClient' (⊂'ClassName' 'Excel.Application')
XL.Workbooks.Add ⍬
XL.ActiveWorkbook.Sheets[⊂'Sheet2'].Index
2


Note that it is the value of ⎕WX in the object, and not in the calling environment, that decides the behaviour:

      ⎕wx←3
⎕using←''
System.DateTime.Parse⊂'2006-09-12'
12/09/2006 00:00:00
⎕wx←1
System.DateTime.Parse'2006-09-12'
LENGTH ERROR
System.DateTime.Parse'2006-09-12'
^
System.DateTime.⎕WX←1
System.DateTime.Parse'2006-09-12'
12/09/2006 00:00:00


Note that, if we expunged the System.DateTime class instead of setting ⎕WX to 1, and repeated the expression, a new DateTime class would be created but it would inherit ⎕WX from its parent (System), where ⎕WX still has the value 3. Using .NET classes in an application where ⎕WX varies within a single APL namespace can therefore lead to unexpected results. It is recommended that applications only use more than one value for ⎕WX as a temporary measure during a conversion project.

Regards,

Vince
Vince|Dyalog
 
Posts: 414
Joined: Wed Oct 01, 2008 9:39 am

Re: OLE Dyalog 10.1 vs OLE Dyalog 13.0

Postby Tranber44 on Wed Nov 14, 2012 1:23 pm

Hello,

Thank you very much for these masterful explanations which I am preciously going to preserve.
Regards

Bertrand
Tranber44
 
Posts: 34
Joined: Mon Jan 11, 2010 4:46 pm


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest