SysObject() and migration to X#

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

SysObject() and migration to X#

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4279
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

SysObject() and migration to X#

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3658
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

SysObject() and migration to X#

Post by wriedmann »

Hi Robert,
thank you very much!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4279
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

SysObject() and migration to X#

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3658
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

SysObject() and migration to X#

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply