xsharp.eu • How to difference between function call and method in the class
Page 1 of 1

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 5:54 am
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

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 6:21 am
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

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 6:35 am
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

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 6:40 am
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()

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 6:43 am
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

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 7:59 am
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,

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 8:08 am
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

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 8:18 am
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,

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 5:59 pm
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

How to difference between function call and method in the class

Posted: Mon Aug 20, 2018 6:14 pm
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