XS0219 warning

This forum is meant for questions and discussions about the X# language and tools
Post Reply
stecosta66
Posts: 88
Joined: Mon Sep 26, 2016 12:59 pm
Location: Italy

XS0219 warning

Post 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
ic2
Posts: 1863
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Re: XS0219 warning

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

Re: XS0219 warning

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

XSharp Development Team
chris(at)xsharp.eu
stecosta66
Posts: 88
Joined: Mon Sep 26, 2016 12:59 pm
Location: Italy

Re: XS0219 warning

Post 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
FFF
Posts: 1589
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Re: XS0219 warning

Post by FFF »

FTR, in VO it doesn't "work", you get no warning, that's all...
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Post Reply