General

Self reference conditional statement

Started by worldoftwilights on .

Sign in or create an account to join the conversation.

4 posts

Topic starter
Hello!

I was wondering if it is possible to have this sort of code:

if(nameoftheobject==banana1) do this
if(nameoftheobject==banana2) do that


this is because I have a cluster of the same object and since i change the code quite a bit, I would love the possibility to just copy and paste another element (which will have a sequential number) and get the result done :)

Hope I made myself clear, let me know.

1000 thanks
Bye for now.
Gio.
Hi
Another option is a variable in each object with the same code - this can then be easily queried from anywhere . . .

More to the point though is where is the code going to run from, what are you wanting to do, what are the other objects etc etc
Code can be structured in numerous ways to achieve the same thing - with varying performance and for various reasons
Encapsulation of objects into containers as modules can help in easing duplication issues

So sorry but no hard and fast answer here - more info needed . . .

MM
Softcore wrote:
getattribute(getobject(), 'name') 
Thanks man! I'll try it ASAP!
Macciza wrote:Hi
Another option is a variable in each object with the same code - this can then be easily queried from anywhere . . .
MM
Thanks Macciza, that's exactly how I've solved it in this moment.

Every object in the cluster has an index variable inside the object and I change only that.
It seems to work smoothly, I'll let you know.

You're right about the lackness of information, but I was asking the question while writing the code, while thinking about the logistics of the interface... Everything was "in the cloud" and I couldn't give more info on that, because I didn't know exactly where I was going with the code :) .


Thanks a lot guys!
See you soon.