xsharp.eu • Miscellaneous questions about converting VO code to X# - Page 5
Page 5 of 5

Re: Miscellaneous questions about converting VO code to X#

Posted: Tue Apr 23, 2024 12:10 pm
by robert
Kees,
Kees Bouw wrote: Tue Apr 23, 2024 10:16 am Found it, it is probably String2Symbol("#NULL_DATE") right?
String2Symbol("NULL_DATE")

Robert

Re: Miscellaneous questions about converting VO code to X#

Posted: Wed May 01, 2024 1:37 pm
by Kees Bouw
Hi all,

In the application I am converting to X# I found that in many places it relies on the fact that NULL_STRING is in fact an empty string. In X# however, NULL_STRING seems to be equal to NULL or NIL. In VO NULL_STRING seems to be just "". This behaviour can be simulated in X# by setting the /vo2 option. But because I want to convert everything to X# I am reluctant to change options which make it more like VO. Also this option initialises every string variable to an empty string automatically which I don't need or want. I am thinking about simply replacing every occurrence of NULL_STRING with "". Before I do that, I would like to ask if anyone knows any reason why that would not be a good idea.

Kees.

Re: Miscellaneous questions about converting VO code to X#

Posted: Wed May 01, 2024 5:15 pm
by Chris
Hi Kees,

I think it's better to just enable the /vo2 option, this is why we introduced it, to help porting applications from VO.

In VO, not only NULL_STRING practically means "", but all locals and class variables are also used like that:

Code: Select all

FUNCTION Start() AS INT
LOCAL c AS STRING
LOCAL o AS TestClass
? c == "" // TRUE
o := TestClass{}
? o:c == "" // TRUE
RETURN 0

CLASS TestClass
EXPORT c AS STRING
END CLASS
When you enable the /vo2 option in X#, the compiler mimics also this behavior. If you do not initialize (or forget to do that) all such vars to "" in X#, all sorts of problems may arise (at runtime...) in cases where your VO code relies on that.

So I'd suggest to just enable the option, nothing wrong about it, it only makes code say 0.001% slower... If you write a new .Net app, it's probably better to not use it, but even if you want to enable it also in this case, there's nothing wrong with it.

Re: Miscellaneous questions about converting VO code to X#

Posted: Mon May 06, 2024 9:19 am
by Kees Bouw
Hi Chris,

Thank you very much for your advice. I have had many warnings about using unassigned local variables (XS0165) and fixed all these so I thought I would not have that problem anymore. I am not sure if X# also warns about using unassigned class variables or other unassigned variables. Also, you are right that other unforeseen problems may arise while there is not much harm in enabling the /vo2 option. So I shall follow your advice and enable the option.

Kees.