fbpx

How to difference between function call and method in the class

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
5 months 2 days ago #1 by Wolfgang Riedmann
Hello,

I have the following code in a (migrated) DLL:
_dll function VpeGetVersion(  ) as int pascal:vpes3271.VpeGetVersion

and
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

Please Log in or Create an account to join the conversation.

More
5 months 2 days ago #2 by Robert van der Hulst
Replied by Robert van der Hulst on topic How to difference between function call and method in the class
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
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
5 months 2 days ago #3 by Wolfgang Riedmann
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

Please Log in or Create an account to join the conversation.

More
5 months 2 days ago - 5 months 2 days ago #4 by Robert van der Hulst
Replied by Robert van der Hulst on topic How to difference between function call and method in the class
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
This email address is being protected from spambots. You need JavaScript enabled to view it.
Last edit: 5 months 2 days ago by Robert van der Hulst.

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
5 months 2 days ago #5 by Wolfgang Riedmann
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

Please Log in or Create an account to join the conversation.

More
5 months 2 days ago - 5 months 2 days ago #6 by Johan Nel
Hi Wolfgang,

wriedmann wrote: Hello,

_dll function VpeGetVersion(  ) as int pascal:vpes3271.VpeGetVersion
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:
class VpeInfo
  static method VpeGetVersion(  ) as shortint pascal:vpes3260.VpeGetVersion
end class
HTH,

______________________
Johan Nel
George, South Africa
Last edit: 5 months 2 days ago by Johan Nel. Reason: Fix the code

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
5 months 2 days ago #7 by Wolfgang Riedmann
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

Please Log in or Create an account to join the conversation.

More
5 months 2 days ago #8 by Johan Nel
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
George, South Africa

Please Log in or Create an account to join the conversation.

More
5 months 1 day ago #9 by Chris Pyrgas

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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
5 months 1 day ago #10 by Wolfgang Riedmann
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

Please Log in or Create an account to join the conversation.