xsharp.eu • Porting VO Code
Page 1 of 4

Porting VO Code

Posted: Wed Jul 19, 2017 12:49 pm
by markus.lorenzi@dvbern.ch
Hi Dev Team

I just tried to convert one of our VO-Programs. I was able to correct the most of the errors.
But These two Things does not compile:

Split Window Class:

SELF:Font := Font{,9,"Arial"}
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand
Fehler XS0144 Cannot create an instance of the abstract class or interface 'Font'


SELF:oDefaultIcon := Icon{ ICONSTANDARD }
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand
Fehler XS0144 Cannot create an instance of the abstract class or interface 'Icon'

Any idea how to solve this?
TIA Markus

Porting VO Code

Posted: Wed Jul 19, 2017 2:00 pm
by Chris
Hi Markus,

Those are strange errors..have you created your own Icon and Font class in the code? Maybe in VO you had added additional methods to the already existing Font/Icon classes? Or maybe there is something else causing the problem, can you send the full code of this class so we can have a look?

Chris

Porting VO Code

Posted: Wed Jul 19, 2017 2:16 pm
by markus.lorenzi@dvbern.ch
Hi Chris

thanks for your fast answer. I attached the solution to this post.
I didn't find an own font class in this Project.

HTH and TIA Markus
MyExplorer.zip
(395.87 KiB) Downloaded 39 times

Porting VO Code

Posted: Wed Jul 19, 2017 3:05 pm
by Chris
Hi Markus,

Thanks for providing the code! The problem is that there's a Font and Icon class defined in the Excel library, which conflicts with the Font and Icon classes in the SDK. There are 2 solutions:

1. Remove the USING Microsoft.Office.Interop.Excel command and supply this namespace when needed, for example change

LOCAL oWorkbooks AS Workbooks

to

LOCAL oWorkbooks AS Microsoft.Office.Interop.Excel.Workbooks

2. Keep the USING Microsoft.Office.Interop.Excel command, but prefix the classes from the SDK with "Vulcan.VO", this is the namespace used by the compiled SDK classes. So for example change

PROTECT oDefaultIcon AS Icon
...
SELF:Font := Font{,9,"Arial"}
...
SELF:oDefaultIcon := Icon{ ICONSTANDARD }

to

PROTECT oDefaultIcon AS Vulcan.VO.Icon
...
SELF:Font := Vulcan.VO.Font{,9,"Arial"}
...
SELF:oDefaultIcon := Vulcan.VO.Icon{ ICONSTANDARD }

Using either way it should compile fine now!

Chris

Porting VO Code

Posted: Thu Jul 20, 2017 8:50 am
by robert
Chris,

Maybe one more addition to your comment about prefixing classes with namespaces.
We now also have the ability to define an alias for a namespace. So you can write:

Code: Select all

USING Excel := Microsoft.Office.Interop.Excel
This allows you to simplify the namespace in your code. Instead of

Code: Select all

LOCAL oWorkbooks AS Microsoft.Office.Interop.Excel.Workbooks
you can then write

Code: Select all

LOCAL oWorkbooks AS Excel.Workbooks
Robert

Porting VO Code

Posted: Thu Jul 20, 2017 9:24 am
by markus.lorenzi@dvbern.ch
Hi Chris, hi Robert

first of all I have to thank for your really fast Responses!
It's a pleasure to work this way.

With These fixes I can compile the solution without Errors. Unfortunately the app crashes on the instantiation of the TreeView object. I commented out the try/catch in the start.prg to get more Details about the error but have no idea whats the reason for the Crash.

Thanks Markus
MyExplorer.zip
(395.63 KiB) Downloaded 35 times

Porting VO Code

Posted: Thu Jul 20, 2017 10:23 am
by wriedmann
Hi Markus,

just a shot in the dark: do you have the cato*.dll files in the application directory? AFAIK the TreeView needs them too.

Wolfgang

P.S. I'm have successfully transported the FTPExplorer to X#, so the ListView/TreeView/SplitWindow work in X#.

Porting VO Code

Posted: Thu Jul 20, 2017 11:00 am
by robert
Markus,

Was this really an app that ran in VO this way or did you copy and paste some code from different VO apps and combine this in the X# app ?

The Treeview and Listview class need a Point and Dimension argument to work properly.
In your MyTreeView class change:

Code: Select all

SUPER(arg1,arg2)
to

Code: Select all

SUPER(arg1,arg2,Point{}, Dimension{})
and in your clas IMSListView make the following change:

Code: Select all

CONSTRUCTOR(oOwner, nId, oPoint, oDim, kStyle) 
	SUPER(oOwner, nId, oPoint, oDim, kStyle)

Code: Select all

CONSTRUCTOR(oOwner, nId, oPoint, oDim, kStyle) 
   IF IsNil(oPoint)
      oPoint := Point{}
   ENDIF	
   IF IsNil(oDim)
      oDim := Dimension{}
   ENDIF	
SUPER(oOwner, nId, oPoint, oDim, kStyle)
I could not completely test your app because I am missing the resources, and I have the impression that not all the code is there.
The Drive array is missing some array elements I think, and element # 2 in each row is not numeric as it is supposed to be.

Robert

Porting VO Code

Posted: Thu Jul 20, 2017 12:42 pm
by Chris
Hi Markus,

In addition to what Wolfgang and Robert said, if the app still doesn't run without errors, can you please send also the VO .aef file so we can try porting it also in our machines?

thanks,
Chris

Porting VO Code

Posted: Thu Jul 20, 2017 9:02 pm
by markus.lorenzi@dvbern.ch
Hi Chris

here is the aef which works well in VO 2.8.
The program is just a sample which I want to use in our next VO Usergroup Meeting to demonstrate the way from VO to X#.

Markus
FeserExplorer.zip
(990.91 KiB) Downloaded 34 times
Attn. Robert: The error with the ListView was my fault as I tried different Things and did a copy&paste mistake.