Transporting VO to XSharp

This forum is meant for questions and discussions about the X# language and tools
leon-ts
Posts: 435
Joined: Fri Feb 03, 2017 1:43 pm

Transporting VO to XSharp

Post 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
Best regards,
Leonid
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Transporting VO to XSharp

Post by robert »

Leonid,

This was done because many people have code that looks like

Code: Select all

IF A.or.B
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
XSharp Development Team
The Netherlands
robert@xsharp.eu
leon-ts
Posts: 435
Joined: Fri Feb 03, 2017 1:43 pm

Transporting VO to XSharp

Post 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)
Best regards,
Leonid
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Transporting VO to XSharp

Post by robert »

Before the code (outside of the entity)

Code: Select all

#pragma warning disable XS0219

and afterwards

Code: Select all

#pragma warning restore  XS0219


Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
leon-ts
Posts: 435
Joined: Fri Feb 03, 2017 1:43 pm

Transporting VO to XSharp

Post by leon-ts »

Robert,

Many thanks!

Best regards,
Leonid
Best regards,
Leonid
leon-ts
Posts: 435
Joined: Fri Feb 03, 2017 1:43 pm

Transporting VO to XSharp

Post 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
Best regards,
Leonid
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Transporting VO to XSharp

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
leon-ts
Posts: 435
Joined: Fri Feb 03, 2017 1:43 pm

Transporting VO to XSharp

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

Transporting VO to XSharp

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

XSharp Development Team
chris(at)xsharp.eu
leon-ts
Posts: 435
Joined: Fri Feb 03, 2017 1:43 pm

Transporting VO to XSharp

Post 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
Best regards,
Leonid
Post Reply