Page 1 of 2
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 11:56 am
by leon-ts
Hi devteam,
After converting AEF using xPorter, an extra space appeared in front of .OR. and .AND. keywords in all lines with conditions.
For example,
Source string:
Code: Select all
IF (nLen == 8<one space>.OR. nLen == 10)
String after conversion:
Code: Select all
IF (nLen == 8<two spaces>.OR. nLen == 10)
My perfectionist feelings hurt
Best regards,
Leonid
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 1:22 pm
by robert
Leonid,
This was done because many people have code that looks like
which compiles fine in VO because a DOT can never be part of an identifier.
However in DotNet the Dot may be used as a namespace delimiter or between a type and a field/property, so there has to be at least a space in front of the .OR.
Robert
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 1:37 pm
by leon-ts
Can I somehow suppress the compiler warning?
XS0219 The variable 'pszOrder' is assigned but its value is never used
that occurs in the following code:
Code: Select all
FUNCTION tDBSetOrder(uOrder := NIL AS USUAL, cBagName := "" AS STRING) AS LOGIC PASCAL
LOCAL pszOrder AS STRING
RETURN VODBOrdSetFocus(cBagName, uOrder, @pszOrder)
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 1:40 pm
by robert
Before the code (outside of the entity)
and afterwards
Robert
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 1:41 pm
by leon-ts
Robert,
Many thanks!
Best regards,
Leonid
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 2:01 pm
by leon-ts
Robert,
I can’t understand why the compiler reports that lOk is not used.
Warning:
XS0219 The variable 'lOk' is assigned but its value is never used
Code:
Code: Select all
FUNCTION tOrdListAdd(cOrdBag AS STRING, uOrder := NIL AS USUAL) AS LOGIC PASCAL
LOCAL lOk AS LOGIC
#pragma warning disable XS0219
LOCAL pPrev AS STRING
#pragma warning restore XS0219
IF ( lOk := VODBOrdListAdd(cOrdBag, NIL) )
IF !IsNil(uOrder)
lOk := VODBOrdSetFocus(cOrdBag, uOrder, @pPrev)
ENDIF
ENDIF
IF !lOk
RETURN _tDoError(#ORDLISTADD)
ENDIF
RETURN TRUE
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 2:10 pm
by robert
Leonid,
I wrote
outside of the entity
You did not do that and added the line to the body of the entity.
As a result of that the #pragma line has ended the function, and the compiler sees this now as
Code: Select all
FUNCTION tOrdListAdd(cOrdBag AS STRING, uOrder := NIL AS USUAL) AS LOGIC PASCAL
LOCAL lOk AS LOGIC
And then it makes perfect sense that lOk is not used.
Change your code to:
Code: Select all
#pragma warning disable XS0219
FUNCTION tOrdListAdd(cOrdBag AS STRING, uOrder := NIL AS USUAL) AS LOGIC PASCAL
LOCAL lOk AS LOGIC
LOCAL pPrev AS STRING
IF ( lOk := VODBOrdListAdd(cOrdBag, NIL) )
IF !IsNil(uOrder)
lOk := VODBOrdSetFocus(cOrdBag, uOrder, @pPrev)
ENDIF
ENDIF
IF !lOk
RETURN _tDoError(#ORDLISTADD)
ENDIF
RETURN TRUE
#pragma warning restore XS0219
And then it compiles fine.
Robert
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 2:23 pm
by leon-ts
Robert,
Oh, ok, thanks!
I just did not understand that by "entity" you meant a function.
It turns out that with this approach, if some other variable is not used within the function, I don’t know about it?
Best regards,
Leonid
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 2:37 pm
by Chris
Hi Leonid,
In order to avoid completely disabling the warning for the entity, maybe refactor your code, so that the variable is used in a dummy call. Something like:
FUNCTION tDBSetOrder(uOrder := NIL AS USUAL, cBagName := "" AS STRING) AS LOGIC PASCAL
LOCAL pszOrder := NULL AS STRING
LOCAL lResult AS LOGIC
lResult := VODBOrdSetFocus(cBagName, uOrder, @pszOrder)
DummyCall(pszOrder)
RETURN lResult
and define somewhere in your library this DummyCall() function that is only used as a way to avoid the warning. Not too elegant, but will work.
Transporting VO to XSharp
Posted: Fri Apr 17, 2020 2:53 pm
by leon-ts
Chris,
Thanks! I'll probably do that.
For such cases, one of the features of the C# language, which I mentioned not so long ago in this forum, would be useful: passing an underscore as a parameter for OUT (and, possibly, REF).
Best regards,
Leonid