Seven or eight years ago, there were a few threads about this error message, encountered when trying to port working Mac apps to iOS. I also recall from that period the opinion that “people who do not understand subclasses have no business using RealBasic.” The combination of the two has me in a bad place.
I have a (very) large desktop app implemented entirely with methods. No subclasses because no classes. It has, however, no pull-down menus, just one window, and on it just one canvas. It seemed like a promising candidate for iOS. (The canvas is manipulated by lots of containers that I should be able to port one at a time once I get the basics working.)
I am nowhere. I cannot even position my canvas without the static reference error, usually with a non-existence error as well.
I do not expect offers of an actual solution, but would much appreciate guidance as to how to get traction on this. Can code in a container manipulate a canvas that is outside the container? If so, must I master classes in order to do it?
I suspect if you post some code that’s provoking this error, other smay help. I don’t do iOS or mobile in general.
Classes are not so bad and are very useful. I use them all over my app. Some are classes with no Super, others are subclasses (e.g. of DesktopCanvas) which therefore have (e.g. DesktopCanvas) as their Super. This latter means that the subclass starts off life with all the abilities of its Super.
A simple class can be made by dragging the Class icon from the Libary to the navigation area. Once done, you can set the name of your new class. Then, for example, add properties to it. For example, you can store in each row of a Listbox (and others), a RowTag. But only one. So if you want, in effect, to store a number of properties in the RowTag, a class is the way to do it. Then you might have code like this (after adding properties x and y to your new class)::
Var mc As myClass
mc = new myClass
mc.x = 27
mc.y = 43
myListbox.RowTagAt(row) = mc
Now I have access to two hidden values in the row.
You’ll need to post the actual error message for us to help. The error you’re getting, and the inevitable conversation about your code structure, are very likely separate discussions.
I’m just guessing but it sounds like you might be running into the fact iOS projects do not have implicit Screens. With Desktop projects, Windows have “Implicit Instance” on by default. This means that in a container (perhaps you really mean a Module?) you could refer to a Canvas on a Window like this:
Window1.Canvas1.Refresh()
Trying to do the same in iOS:
Screen1.Canvas1.Refresh()
will result in a compile error because Screen1 is the class and not an instance.
One way you can simulate the Implicit Instance behavior is to add a global property to one of your modules:
Screen1Instance As Screen1
In the Opening event of Screen1, assign it to the global property:
Screen1Instance = Self
Then in your modules, you can refer to Screen1 using Screen1Instance:
Screen1Instance.Canvas1.Refresh()
I would certainly never recommend this design for someone starting out, but if it allows you to get your existing code up and running quickly, you might find it worthwhile.
Wow. Thank you Paul. I might indeed “find it worthwhile.” Going through the “instance” approach does indeed seem to be accepted by the compiler for iOS.
Before I start attacking my iOS error list (currently at 1182), I do want to reconfirm a couple of points you made.
First, I just need to create the instance variable (equal to my screen) one place in one module and I can use it everywhere once I set it in the screen opening event.
Second, I can preserve a single source by, in the case of your example, using something like:
#If TargetDesktop Then
Window1.Canvas1.Refresh()
#Elseif TargetMobile Then
Screen1Instance.Canvas1.Refresh()
#Endif
Yes.
Yes, although TargetiOS might be a better choice.