Pragma mystery

The top three lines appear when I run the program. Could somebody please explain what they mean? It all worked Ok yesterday as far as I remember …

[code]Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean
#pragma unused me
#pragma reset
const CurrentMethodName = “Wnd1.ScoreLB.CellBackgroundPaint”

Me.Height = (me.listcount +1) * (me.textSize + 2) //20
if row < me.listcount then
If row = 0 then
g.foreColor= &cff0000
g.fillrect 0,0,g.width,g.height
Else
select case me.list (row)
case " Pegging stage"
g.forecolor = &cffc200
case " Score the Hands"
g.forecolor = &cffc200
case " Score the Crib (" + gDealerName + “)”
g.forecolor = &cffc200
case " Final Scores"
g.forecolor = &cffc200
case else
g.forecolor = &cc6c6c6
end select

  g.fillrect 0,0,g.width,g.height
  'return true
  
end if[/code]

end if

End Function

#pragma unused me

indicates that you are NOT using the variable/object “ME”, and to not warn you about it during a project analyze.

HOWEVER, you ARE using “ME”, so remove that line

#pragma reset

not sure, but I’d guess it removes any previously defined pragmas, and therefore it too is useless

You can remove both pragma lines as far as i can tell.
Same as Dave mentioned.

They show in the debugger view only ?
What version of Xojo ?

Do NOT set CurrentMethodName as a constant. CurrentMethodName is a Xojo function that always returns the current method name anyway.

Note: I just tested and it’s not allowed anyway.

@Kem Tekinay he’s right. CurrentMethodName is a function.

Example :

App.errWinVentana = me.Title App.errWinMethod = CurrentMethodName

suggested modification;

 const myCurrentMethodName = "Wnd1.ScoreLB.CellBackgroundPaint"

I bet he saw this in the debugger and not his actual code. Sometimes it’s possible to make a function break on the header, usually because of a stack over flow, and this makes the hidden lines added by the compiler visible, such as the current method name constant. I’ve only seen this a couple times on iOS projects though, and it seems random as to whether it happens or not as far as I can see so I’ve never filed a bug report.

Wow, is that right? That puts the original post in a new light and makes perfect sense.

  #pragma unused me
  #pragma reset

Indeed. Seems an IDE error showing these.

No error. Everything here is expected behavior, except that it can sometimes be seen in the debugger.

I was editing my message and you were fast. Yeah, I meant an IDE bug.

#pragma unused me // this is a legit pragma I use it all the time as described above
#pragma reset // never seen this one… so it might be the source of the OP issue

#pragma reset makes perfect sense, given that pragmas do not follow function calls. That would be the internal mechanism they must use to clear all the pragmas for the newly called method. If Jason is correct, then the real question becomes, What caused the crash in the OP’s code, and is THAT something that the OP can fix, or is that some internal Xojo error?

Was there any indication of an Exception? If you (the OP) press Resume, do you get an Unhandled Exception event or message box?

This pragma has actually already been removed from the language in 2015r3. Pretend it doesn’t exist.

Darn, now I’m going to have to go back and remove that from all the projects I wasn’t using it in.

AFAIK if a pragma does not exist, it does not trigger any error. It seems to simply be ignored.

@KemT

I say go back to your projects and add that pragma so that once you go back to remove it you will have something to remove :stuck_out_tongue:

(You should read my post again.) :stuck_out_tongue:

[quote=218547:@brian franco]@KemT

I say go back to your projects and add that pragma so that once you go back to remove it you will have something to remove :P[/quote]

Yes, that seems to be the sensible thing to not do.

Pretend you did that too :stuck_out_tongue: