xsharp.eu • XS0219 warning
Page 1 of 1

XS0219 warning

Posted: Thu Dec 05, 2024 8:28 pm
by stecosta66
Hi All,

I have this method but getting the warning

XS0219: The variable 'cFName' is assigned but its value is never used

Code: Select all

ASSIGN Value( uValue )
	LOCAL obBrowser	AS bBrowser
	LOCAL lHasOrder	AS LOGIC
	LOCAL lSuccess	AS LOGIC
	LOCAL cFName	AS STRING

	IF !IsNil( uValue )
		obBrowser	:= SELF:oDCbBrowser

		IF obBrowser <> NULL_OBJECT
			oServer := obBrowser:Server

			IF oServer <> NULL_OBJECT
				lHasOrder := SELF:oServer:OrderINfo( DBOI_NUMBER ) > 0

				IF lHasOrder
					lSuccess := SELF:oServer:Seek( uValue, .F. )

				ELSE
					cFName := Symbol2String( SELF:symReturnField )
					lSuccess := SELF:oServer:Locate( "uValue == cFName" )

				ENDIF
			ENDIF

			IF !lSuccess
				SELF:oServer:GoTop( )
			ENDIF
		ENDIF
	ENDIF

RETURN uValue
It's not true that cFName is never used, it is used inside string. oServer is a bArrayServer with 32 records.

How can solve this?

Stefano

Re: XS0219 warning

Posted: Thu Dec 05, 2024 9:59 pm
by ic2
I think it looks like it is never used as the line in which you use it, the Locate, uses it within a string. I have had this warning also on places where it is explainable but not really correct.

Dick

Re: XS0219 warning

Posted: Fri Dec 06, 2024 12:27 am
by Chris
Hi Stefano,

As Dick said, the value assigned to the local is not actually used. You are trying to use it inside the string, but this will not work, the macro compiler (which will be called later by Locate(), to compile the string into an expression) is not aware of the local with that name, this wouldn't work in VO either. Is this existing code ported from VO, or is it new code?

Re: XS0219 warning

Posted: Fri Dec 06, 2024 4:54 am
by stecosta66
Hi Dick and Chris,

I'm aware that the compiler cannot get it as it is within a string that will be macrocompiled later.
It is VO code being ported, and in VO it works.

ok, i will find a workaroud to that.

thanks
Stefano

Re: XS0219 warning

Posted: Fri Dec 06, 2024 6:56 am
by FFF
FTR, in VO it doesn't "work", you get no warning, that's all...