order of customproperties

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

order of customproperties

Post by jmburnod » Mon Feb 07, 2011 7:31 pm

Hi All,
I watch the customproperties are sorted by alphabetic order automaticaly
It is possible to keep the order by entry ?

Best

Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: order of customproperties

Post by dunbarx » Mon Feb 07, 2011 10:10 pm

Hi.

The property inspector lists them as the are created. But the customProperties is stored as an array, and I believe it is not managable the way you want it unless you combine the array data back into a normal variable, and work from there.

Of course, you could always add a marker to a custom property as you create them, as in "myCustprop 1", "myCustProp 2", etc. and deconstruct the array that way. It would be easy to use another custom property that kept track of all custom properties you created, so that even if you deleted some the index value would still be maintained. So if you first set the custPropCounter to 0, you can then write:

on mouseUp --this is in the object script
repeat 3
set the custPropCounter of me to the custPropCounter of me + 1
put "myCustProp" && the custPropCounter of me into temp
set the temp of me to random(999) --your values here, this is just to see how they build...

end repeat
end mouseUp

The list in the property inspector is ordered. Try this two or three times and you will see the properties listed as the build. But now you can also get the customProperties array itself, combine it however you want to, and sort by the last word of each.

Craig Newman

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: order of customproperties

Post by jmburnod » Mon Feb 07, 2011 10:40 pm

Hi Craig,

Thank for your reply.
I need (for lisibility) to keep signifiant words for customproperties and i want have an order without integer.
I will test this way :
I keep the actual name and i create a new customprop it contains the name of the customprop in the order i defined
Something like that (no tested)

Code: Select all

function GetPropInMyOrder
   put empty into GetPropInMyOrder
   put the MyListProp of this stack into tPropStack
   repeat for each line tProp  in tPropStack
      do "put the tProp of this stack &return after rGetPropInMyOrder"
   end repeat
   delete last char of rGetPropInMyOrder
   return rGetPropInMyOrder
end GetPropInMyOrder
Some news in a next post
Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: order of customproperties

Post by jmburnod » Wed Feb 09, 2011 10:51 am

Hi All,

This script work. The "do" command is not necessary (a surprise for me)

Code: Select all

function LesPropUnGrp pLeGroup 
   put empty into rLesPropUnGrp
   put the MyPropOrder of group pLeGroup into bufProp --•• one line by prop
   repeat for each line UneLi in bufProp
      put the Uneli of group pLeGroup into ContProp
      put UneLi&&ContProp&"," after rLesPropUnGrp
   end repeat
   delete last char of rLesPropUnGrp
   return rLesPropUnGrp --•• a list of items of two words "nameProp contProp"
end LesPropUnGrp
Best

Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: order of customproperties

Post by Klaus » Wed Feb 09, 2011 12:59 pm

Bonjour Jean-Marc,
jmburnod wrote:...The "do" command is not necessary (a surprise for me)...
Yes, you can use a variable if it resolves into a valid name of a custom property!

Works:
...
put ("cMyCP" & 1) into tPropName
answer the tPropname of this stack
...

Does not work:
...
answer the ("cMyCP" & 1) of this stack
...


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: order of customproperties

Post by jmburnod » Wed Feb 09, 2011 4:58 pm

Salut Klaus
Yes, you can use a variable if it resolves into a valid name of a custom property!
Vielen Dank für diese Genauigkeit
Bis bald
Jean-marc
https://alternatic.ch

Post Reply