xsharp.eu • SysObject() and migration to X#
Page 1 of 1

SysObject() and migration to X#

Posted: Mon Apr 12, 2021 4:22 am
by wriedmann
Hello,
I have looked at a VO application that a customer would like to migrate to X#.
This application makes massive use of the SysObject() call, in code pieces like this:

Code: Select all

cCesDir := SysObject():CesDir +Left( cTmp, 6 )
if SysObject():NoFigli( self )
	SysObject():FiltroWrite( nil,1)
	SysObject():FiltroRecMove()
	self:EndWindow()
endif
How could this call be replaced?
The X# compiler gives me the error

Code: Select all

error XS0619: 'XSharp.VO.Functions.SysObject(params XSharp.__Usual[])' is obsolete: ''SysObject()' is not supported'
Thank you very much!
Wolfgang

SysObject() and migration to X#

Posted: Mon Apr 12, 2021 6:36 am
by robert
Wolfgang,
I think we can add this function in the next build. It will :
- save the object in global state when you pass it an object
- return the object from global state when you call it without arguments
Nothing fancy really.
Of course this will require the /lb (allow late binding) compiler flag to compile because the return type of SysObject() will be "object".
Robert

SysObject() and migration to X#

Posted: Mon Apr 12, 2021 6:41 am
by wriedmann
Hi Robert,
thank you very much!
Wolfgang

SysObject() and migration to X#

Posted: Mon Apr 12, 2021 7:38 am
by robert
Wolfgang,
I had a quick look at this.
SysObject in VO does 2 things:
1) It acts as a global object store
2) it registers an object that will be used by send when no object is specified but another data type.
I can implement 1) without problems.
2) is impossible in .Net because everything inherits from Object.

The example code you uploaded seems to only use feature 1).

Robert

SysObject() and migration to X#

Posted: Mon Apr 12, 2021 7:49 am
by wriedmann
Hi Robert,
thank you very much!
Yes, I have looked in the application to see what use is being made, and it seems it is used only as global object store.
I have never used that myself (in VO, I store global variables in the App object, and in X# I use a special singleton class for this), and specially the second functionality seems powerful, but very risky.
Wolfgang