Self variables to Designer codes.

Feature requests for future versions can be voiced here
Post Reply
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Self variables to Designer codes.

Post by Bugala »

Suppose I have 10 boxes in my designer project, and I want to keep track of how many times each of them have been clicked.

code would be roughly:

Code: Select all

OnCLick:
boxa=boxa+1
text="Total amount of clicks on box a = "..boxa
Problem is, if i want each of the ten boxes to do the same, I have to write them each their own code with variables boxa, boxb, boxc...

What I would really like is to simply instead of choosing to "Run Code" to choose "Run Program".

And then this Program would have a comman something like:

Selfvariable box

And then it would simply refer to:
box = box+1

And each time I would click on any of these boxes, the program would take care of keeping track of the clicks.

Not only would this save time by not needing to write same code several times, but in addition, if I want to make even a minor change to my code, then i have to do it 10 times now, when instead, I could simply alter the code that contains the self variable command that understands to use its own variable for each object that program is used.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Self variables to Designer codes.

Post by Bugala »

I noticed I had misunderstood something here.

I thought "Run Program" referred to, "run Hollywood program".

Hence, another feature request. possibility to pick "Run Hollywood Program". I know that is basically same thing as "Run Code", but it would be handier picking stuff from list, especially if you decide to use same program in many program.

However, to use same program in many designer products, would really need that "Self Variable" thing implemented, so that for example if i want to keep track of clicks on a button, i could each time just pick that "Run Hollywood Program" code, and it would work wihtout need to do anything else.

EDIT: just realised there is actually possibility in "Run code" to insert code from disk, so this does the trick already, although not as conveniently as "Run Hollywood Program" - would, but then again, i rather not have bloated program for nothing.

But Self Variable request stays.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Self variables to Designer codes.

Post by airsoftsoftwair »

This should already be possible by using the SetObjectData() and GetObjectData() functions to store private data inside the Hollywood layer. E.g. something like this:

Code: Select all

box = GetObjectData(#LAYER, uid$, "box")   ; get current click count from private layer data
box = box + 1
text="Total amount of clicks on box a = "..box
SetObjectData(#LAYER, uid$, "box", box)   ; store updated click count in private layer data
uid$ is the UID of your object (can be configured in the name dialog)
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Self variables to Designer codes.

Post by Bugala »

Ah, thanks. That will solve my problem nicely!
Post Reply