[22 Apr 2010] Using text handlers instead of integers

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
Elwood
Posts: 36
Joined: Thu Aug 18, 2016 8:00 pm

[22 Apr 2010] Using text handlers instead of integers

Post by Elwood »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 22 Apr 2010 20:39:48 +0200

Hello,

you can use LoadBrush( 1, "path to picture") but not LoadBrush( "pic_background", "path to picture")

in a large project (100 or more brushes), it is a lot easier to remember a name in your native language than just a number.

Is there some plan to change this?

Thanks.
User avatar
Tuxedo
Posts: 338
Joined: Sun Feb 14, 2010 12:41 pm

[22 Apr 2010] Re: Using text handlers instead of integers

Post by Tuxedo »

Note: This is an archived post that was originally sent to the Hollywood mailing list on 22 Apr 2010 22:10:31 +0200

Hi!
you can use LoadBrush( 1, "path to picture") but not LoadBrush( "pic_background", "path to picture")

in a large project (100 or more brushes), it is a lot easier to remember a name in your native language than just a number. Is there some plan to change this?
Why simply dont use the automatic id selection doing that:

Code: Select all

MyNiceBrush = LoadBrush(Nil, "path to pic")
and than(for example)

Code: Select all

DisplayBrush(MyNiceBruh, 0 ,0)
You miss that Hollywood functionality? Or I missunderstand you question?

However I hope that helps!
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Elwood
Posts: 36
Joined: Thu Aug 18, 2016 8:00 pm

[22 Apr 2010] Re: Using text handlers instead of integers

Post by Elwood »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 22 Apr 2010 23:15:16 +0200

Hello,
MyNiceBrush = LoadBrush(Nil, "path to pic") DisplayBrush(MyNiceBruh, 0 ,0)
Oh, I overlooked that one. It's a bit unusual to expect a return but that will do it. Thanks.
User avatar
TheMartian
Posts: 109
Joined: Sun Feb 28, 2010 12:51 pm

[23 Apr 2010] Re: Using text handlers instead of integers

Post by TheMartian »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 23 Apr 2010 18:54:03 -0000

Hi

You can also get the best of both worlds by storing the indexes returned in a table using string indexes... something like this:

Code: Select all

myBrushes={}
myBrushes["Fred"]=LoadBrush(Nil,"path to pic")
Then to manage your brush, just use myBrushes["Fred"] as the index for the brush. The nice thing is that ["Fred"] may also be a variable that is initalized to "Fred" or some other string. This often allows you to write a generic routine, that you can just feed with meaningfull names for your brushes.

regards Jesper
Elwood
Posts: 36
Joined: Thu Aug 18, 2016 8:00 pm

[24 Apr 2010] Re: Using text handlers instead of integers

Post by Elwood »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 24 Apr 2010 22:11:28 +0200

Hello,
myBrushes["Fred"]=LoadBrush(Nil,"path to pic")
Ok but simple variables probably eat less memory than a table :-)
User avatar
TheMartian
Posts: 109
Joined: Sun Feb 28, 2010 12:51 pm

[25 Apr 2010] Re: Using text handlers instead of integers

Post by TheMartian »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 25 Apr 2010 19:50:12 -0000

Hi

He he! I must admit to not being worried about the extra memory used to initialize a table. If I do something like:

Code: Select all

t1={}
t2={}
t3={}
NPrint(t1,t2,t3)
... the start address of each table is different by $28. If this is an indication of the size of the basic table structure (I have to say I don't know if this is so.) I think it is a small price to pay compared to the advantages. Besides you only need one table to store pointers to your brushes and any brush will then be accessible by name with a command like:

Code: Select all

SaveBrush(MyBrushes[name$],"Ram:"..name$)
...and allow you to do all the lovely things to your table that you can do to tables in general. I am primarily thinking about metatable tricks.

regards Jesper
Locked