Case IS help

This produces the following error 'Static reference to instance

select case starty(x)
case is < view1.WaveCanvas.Height/2
g.DrawLine(stime(x)*tx, ver, stime(x)*tx, set(x)4amp)
case is > view1.WaveCanvas.Height/2 ’
g.DrawLine(stime(x)*tx, ver, stime(x)*tx, set(x)0.5amp)
end select

What is “IS”? Perhaps the name isn’t allowed.

You should post the complete error message. It tells something like:

[quote=288063:@Martin Fitzgibbons]This produces the following error 'Static reference to instance

select case starty(x)
case is < view1.WaveCanvas.Height/2
g.DrawLine(stime(x)*tx, ver, stime(x)*tx, set(x)4amp)
case is > view1.WaveCanvas.Height/2 ’
g.DrawLine(stime(x)*tx, ver, stime(x)*tx, set(x)0.5amp)
end select[/quote]

select case true
case starty(x) < view1.WaveCanvas.Height/2
g.DrawLine(stime(x)*tx, ver, stime(x)*tx, set(x)4amp)
case starty(x) > view1.WaveCanvas.Height/2 ’
g.DrawLine(stime(x)*tx, ver, stime(x)*tx, set(x)0.5amp)
end select

As far as I can see it the error lies not in the Case Is < … and Case Is > …. It is valid code in Xojo and will work.

The error indicates that he is calling a method on a class instead of an instance of that class.

Are you sure WaveCanvas exists on the view ? Could it be a custom canvas ?

Which one?

The issue is not with the select case, or the use of is. This works

[code] dim starty as integer

select case starty
case is < 0
system.debuglog “minus”
case is >= 0
system.DebugLog “over”
end select[/code]

That leaves only WaveCanvas a possible reason for the static reference exception. I bet WaveCanvas is the name of the custom canvas, and the instance is probably named WaveCanvas1.

WaveCanvas is a standard canvas

Starty(x) holds points on the canvas as integers

I am on a different view to where the WaveCanvas is and want to test if the point in the array is above or below the half way point of the canvas in view1

view1.WaveCanvas.Height/2

Full Error Msg:

‘Static reference to instance method: call this on an instance of class View1.View1’

.

So it’s not the wavecanvas, but the view – you have a class view1, but you need to address the instance of it.

That is the heart of the problem. In iOS, addressing a control on another view is not as simple as you think. Views do not have implicit instanciation.

See
https://forum.xojo.com/18799-static-reference-to-instance-method/0

Ok, thanks for that. I guess I can store the value in a Global property to make it easier.

A dictionary can do very nicely.