[Gambas-user] Declaring 'Public pbSwitch As Object[16]' throws error 'Syntax error in FMain.class:3'
Doug Hutcheson
owlbrudder at ...626...
Wed Aug 16 02:35:58 CEST 2017
On Wed, 2017-08-16 at 02:02 +0200, Tobias Boege wrote:
> On Wed, 16 Aug 2017, Doug Hutcheson wrote:
> > Thanks for the explanation, Tobias. Having fixed the declaration, I
> > am
> > able to run the code, but all I see is an empty form with no
> > controls.
> > Sigh. I will keep hacking until I understand enough to make it
> > work.
> >
>
> In case you don't want to figure it out on your own (although you
> didn't
> ask), this is most likely because the code uses the Picture[] cache.
> It accesses Picture["imgSwtchOn.png"] and Picture["imgSwtchOff.png"],
> but you probably don't have those files in your application (you
> don't
> unless you added them on your own). Since Picture[] is the picture
> cache,
> it won't raise an error if the named pictures aren't found and
> returns a
> silent Null instead. Assigning Null to a PictureBox.Picture clears
> the
> PictureBox. This is why you don't see anything.
>
> Actually this example is horrible. Not only uses it resources which
> aren't available by default, it also relies on the geometry of the
> PictureBoxes and Mouse coordinates to identify which PictureBox
> raised the event, instead of simply using Last. And then it
> needlessly
> uses Object instead of PictureBox, and uses a *bitmask* to store the
> on/off state of the pictures instead of just the PictureBox's Tag
> property. Not to mention it isn't indented properly. There is a high
> density of things I would advise to avoid here. Why did you choose
> this of all to learn from? :-)
>
> I updated the example and it should work out of the box now.
>
> Regards,
> Tobi
>
Thanks for making me smile, Tobi. I will now download the corrected
version and use that as my learning platform. I must admit, the
indentation was not to my liking, but I thought "well, it is on the
site as an example, so it must be correct". Chuckle.
Kind regards,
Doug
More information about the User
mailing list