This forum is meant for questions and discussions about the X# language and tools
stecosta66
Posts: 88 Joined: Mon Sep 26, 2016 12:59 pm
Location: Italy
Post
by stecosta66 » Thu Dec 05, 2024 8:28 pm
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
Post
by ic2 » Thu Dec 05, 2024 9:59 pm
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
Chris
Posts: 4977 Joined: Thu Oct 08, 2015 7:48 am
Location: Greece
Post
by Chris » Fri Dec 06, 2024 12:27 am
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
Post
by stecosta66 » Fri Dec 06, 2024 4:54 am
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
Post
by FFF » Fri Dec 06, 2024 6:56 am
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)