How to difference between function call and method in the class

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to difference between function call and method in the class

Post by wriedmann »

Hello,

I have the following code in a (migrated) DLL:

Code: Select all

_dll function VpeGetVersion(  ) as int pascal:vpes3271.VpeGetVersion
and

Code: Select all

class VpeInfo
method VpeGetVersion() 
// _DLL function VpeGetVersion(  ) as shortint pascal:vpes3260.VpeGetVersion
	return VpeGetVersion()
end class
In VO this works well, and I need the wrapper because the DLL is loaded with LoadLibrary() and the class is created with CreateInstance().
In X#, this code creates a StackOverFlow exception because the method calls itself in a loop instead of calling the function of the same name, but in another module.
The DLL is compiled in VO dialect.

Is there something I can do to change this behaviour other than to rewrite the entire interface to the DLL?
I cannot change the class because I use it in many VO applications.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4523
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to difference between function call and method in the class

Post by robert »

Wolfgang,
This has been reported by someone else and is fixed in the next build. From the what's new from that build:
"Functions now Always take precedence over methods. If you want to call a method inside the same class you need to either prefix it with the typename (for static methods) or with the SELF: prefix. If there is no conflicting function name then you can still also call the method with just its name."

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to difference between function call and method in the class

Post by wriedmann »

Hi Robert,

is there anything I can do until then?

Prefixing this call with "Functions.VpeGetVersion()" gives

error XS0117: 'Functions' does not contain a definition for 'VpeGetVersion' 220,19 VPEInfo class.prg Vpe7SNet

but Reflector shows that there is a class Functions with a static method VpeGetVersion().

Wolfgang
P.S. during my flights I have worked many hours on this DLL - it is my printing DLL that is needed in all my VO applications
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4523
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to difference between function call and method in the class

Post by robert »

Wolfgang,

A Quick solution is to prefix the _Dll function like in:
_dll function _VpeGetVersion( ) as int pascal:vpes3271.VpeGetVersion

method VpeGetVersion()
return _VpeGetVersion()
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to difference between function call and method in the class

Post by wriedmann »

Hi Robert,

thank you! I will do that if there are no other solutions.

This method is only one of about 20 I need, but I had taken it as sample for the others.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

How to difference between function call and method in the class

Post by lumberjack »

Hi Wolfgang,
wriedmann wrote:Hello,

Code: Select all

_dll function VpeGetVersion(  ) as int pascal:vpes3271.VpeGetVersion

Code: Select all

class VpeInfo
method VpeGetVersion() 
// _DLL function VpeGetVersion(  ) as shortint pascal:vpes3260.VpeGetVersion
	return VpeGetVersion()
end class
I have used the following with success, not sure it will in your scenario though:

Code: Select all

class VpeInfo
  static method VpeGetVersion(  ) as shortint pascal:vpes3260.VpeGetVersion
end class
HTH,
______________________
Johan Nel
Boshof, South Africa
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to difference between function call and method in the class

Post by wriedmann »

Hi Johan,

I have the entire DLL interface in one file/module because this can change between new versions of the VPE dll.

All the other code is in separate modules.
But I had to apply so much changes that this code is not more compatible between VO and X#.

Finally, after more than two years (where I have started and suspended the migration many times), my report engine now works also in X# - but only with the VO GUI classes. But it will take only a few hours to make it work also with WinForms.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

How to difference between function call and method in the class

Post by lumberjack »

Hi Wolfgang,
I do understand. What I tried to show is that you don't have to first define a _DLL, you can directly create a STATIC METHOD with the details of the Win32 API Call.
Regards,
______________________
Johan Nel
Boshof, South Africa
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to difference between function call and method in the class

Post by Chris »

wriedmann wrote: Finally, after more than two years (where I have started and suspended the migration many times), my report engine now works also in X# - but only with the VO GUI classes.
Hey, very very glad to hear this!

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to difference between function call and method in the class

Post by wriedmann »

Hi Chris,
Hey, very very glad to hear this!
you can be sure that I'm really happy myself!

It was worth the time working on the flights instead of reading a book.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply