xsharp.eu • What am I doing wrong here please?
Page 1 of 1

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 5:14 am
by Anonymous
Among many "RETURN" warnings I'm getting, I'm also getting this:

METHOD CurrentJob()
LOCAL oReport AS RpReport
LOCAL cJobName,cPrint2Filename,cCaption,cMessage AS STRING
MEMVAR cSearch

SELF:Pointer := Pointer{ POINTERHOURGLASS }
cSearch := SELF:Server:FIELDGET(#CLCode)

oReport := RpReport{ SELF, "Joblist.RPT" }

IF oReport:IsValid

cJobName := "Current Jobs Listing"
cPrint2Filename := "REPORT.PRN"
cCaption := cAppVersion +" : Report Preview"
cMessage := "Printing in progress..."

oReport:FilterExpression := "details.CLcode == cSearch"
oReport:PrintPreview(cJobName,cPrint2Filename,cCaption,cMessage,,SW_SHOWMAXIMIZED)

SELF:Pointer := Pointer{ POINTERARROW }

ENDIF

oReport:Close()
RETURN SELF

The error message is:error XS9002: Parser: unexpected input 'ENDIF' 227,1 Window Addons.prg Business Manager 1

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 8:14 am
by FFF
If your report fails, you are stuck with the hourglass :;, but apart from this I don't see a reason for the error, sorry.

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 8:20 am
by wriedmann
Hello,

IMHO the error stays in the entity before this one.

Please post the entire prg file.

Wolfgang

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 8:58 am
by lumberjack
BiggyRat wrote:Among many "RETURN" warnings I'm getting, I'm also getting this:

Code: Select all

METHOD CurrentJob() 
LOCAL oReport AS RpReport
LOCAL cJobName,cPrint2Filename,cCaption,cMessage AS STRING
MEMVAR cSearch

SELF:Pointer := Pointer{ POINTERHOURGLASS }
cSearch := SELF:Server:FIELDGET(#CLCode)

oReport := RpReport{ SELF, "Joblist.RPT" }

IF oReport:IsValid

  cJobName 		:= "Current Jobs Listing"
  cPrint2Filename	:= "REPORT.PRN"
  cCaption		:= cAppVersion +" : Report Preview"
  cMessage		:= "Printing in progress..."

  oReport:FilterExpression := "details.CLcode == cSearch"
  oReport:PrintPreview(cJobName,cPrint2Filename,cCaption,cMessage,,SW_SHOWMAXIMIZED)

  SELF:Pointer := Pointer{ POINTERARROW }

ENDIF

oReport:Close() 
RETURN SELF
The error message is:error XS9002: Parser: unexpected input 'ENDIF'
As Karl indicated the code does seem fine. That error is normally associated with:

Code: Select all

IF True
  // IF True
  ENDIF
ENDIF // Error unexpected ENDIF
Just some observations.
  • Why not strict type this method, METHOD CurrentJob() AS VOID|LOGIC
  • MEMVAR cSearch, I would change that to LOCAL

Code: Select all

LOCAL cSearch AS STRING
oReport:FilterExpression := "details.CLcode == #v#":Replace("#v#", cSearch) // This might be a runtime error , is CLcode a C/N field?
  • RETURN SELF // Do you really need to return the object?

    Code: Select all

      RETURN [lSuccess] // Just preference, but a "cleaner" solution
      
    Regards,

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 9:02 am
by lumberjack
Hi Wolfgang,
wriedmann wrote: IMHO the error stays in the entity before this one.
You are correct, I think the problem is in :FilterExpression("details.CLcode == cSearch"), which I tried to "fix" in my example.
Regards,

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 1:37 pm
by Chris
Most likely it's the "MEMVAR", those are not supported (yet) and this desyncs the parser, reporting an error at a later line. Just convert it to a LOCAL as Johan suggested and the error will go away.

Although I assume you do use that MEMVAR later in filter expressions, so simply turning it them to a LOCAL will not be enough for you. If that's the case, then it is probably a good idea to wait a little bit more, until the X# runtime and compiler does support MEMVARs. Most of the base work has been done already, so it should not take too long.

What am I doing wrong here please?

Posted: Sun Mar 03, 2019 2:50 pm
by lumberjack
Hi Chris,
Chris wrote: Although I assume you do use that MEMVAR later in filter expressions, so simply turning it them to a LOCAL will not be enough for you. If that's the case, then it is probably a good idea to wait a little bit more, until the X# runtime and compiler does support MEMVARs. Most of the base work has been done already, so it should not take too long.
If he has a "fixed" filter expression it can be overcome with the way I showed:

Code: Select all

oReport:FilterExpression := "details.CLcode == #v#":Replace("#v#", cSearch)
Just have to " 'cSearch' " if a string type.

Regards,