Miscellaneous questions about converting VO code to X#

This forum is meant for questions and discussions about the X# language and tools
User avatar
robert
Posts: 4296
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Miscellaneous questions about converting VO code to X#

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Kees Bouw
Posts: 100
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

Re: Miscellaneous questions about converting VO code to X#

Post 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.
User avatar
Chris
Posts: 4606
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Miscellaneous questions about converting VO code to X#

Post 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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
Kees Bouw
Posts: 100
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

Re: Miscellaneous questions about converting VO code to X#

Post 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.
User avatar
Kees Bouw
Posts: 100
Joined: Wed Nov 06, 2019 11:35 am
Location: Netherlands

Re: Miscellaneous questions about converting VO code to X#

Post by Kees Bouw »

The application that I have to convert to X# (which I did not write and has almost no documentation or comments) uses some MAPI code. If anybody has experience with this, I have a few questions.

- The VO version uses a library called "MAPI.H" which defines MAPI classes, functions etc. using a lot of memory manipulation with pointers and buffers, very scary stuff. Is there a modern dot-net MAPI library that can be used instead?

- Where does this MAPI.H VO library come from, any ideas?

- I have tried to add a reference to "msapi32.ocx" but this gives the error "Operation is not valid due to the current state of the object". Would it be useful to use this ocx in some other way and if so, where can I find examples and documentation?

- After importing the code with VOXPorter, I get errors like these:

Code: Select all

LOCAL aRecip AS DWORD PTR

aRecip := PTR(DWORD, MemAlloc(ALen(oMessage:RecipList) * _SIZEOF(DWORD)))
Error XS9061 The "PTR(..) operation" is not allowed for method or function calls. If the method or function returns a pointer then consider using the (<Type> PTR) syntax instead.
What is the best way to fix this?

Kees.
Post Reply