Delete Custom Property

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Delete Custom Property

Post by Da_Elf » Tue Jul 29, 2014 10:13 pm

How do i go about removing a custom property
ive tried setting it to empty, setting it to false, using delete and using remove

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Delete Custom Property

Post by [-hh] » Tue Jul 29, 2014 10:27 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:10 pm, edited 1 time in total.
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: Delete Custom Property

Post by Da_Elf » Tue Jul 29, 2014 10:35 pm

i dont get it. a custom property isnt a variable

if i type

Code: Select all

on mouseUp
   set the cMyProperty of the stack "myMainStack" to "something"
end mouseUp
then it will create a custom property in that stack called cMyProperty which can be called like

Code: Select all

answer the cMyProperty of the stack "myMainStack"
if i wanted to cleanup the custom properties im looking to delete some of them

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: Delete Custom Property

Post by magice » Tue Jul 29, 2014 10:53 pm


[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Delete Custom Property

Post by [-hh] » Tue Jul 29, 2014 10:56 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:10 pm, edited 1 time in total.
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: Delete Custom Property

Post by Da_Elf » Tue Jul 29, 2014 11:14 pm

the code

Code: Select all

set the customKeys of this stack to empty
will totally clear out all of the customProperties i want to just remove 1 of them. It has to be done via script so doing it through the inspector is not an option

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

Re: Delete Custom Property

Post by jmburnod » Tue Jul 29, 2014 11:34 pm

Hi,

Try this

Code: Select all

on delprop pVar
   put the customkeys of this stack into myArray
   delete variable MyArray[pVar]
   set the customproperties of this stack to myArray
end delprop
Best
Jean-Marc
https://alternatic.ch

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Delete Custom Property

Post by [-hh] » Wed Jul 30, 2014 12:23 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:10 pm, edited 1 time in total.
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: Delete Custom Property

Post by Da_Elf » Wed Jul 30, 2014 12:35 am

is that to be run as a command or function?

never mind it worked like a dream

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Delete Custom Property

Post by [-hh] » Wed Jul 30, 2014 12:43 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:11 pm, edited 1 time in total.
shiftLock happens

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Delete Custom Property

Post by Mark » Fri Aug 01, 2014 9:24 am

Hi,

Jean-Marc's approach doesn't use offset and should therefore be much faster if you want to delete a large range of custom properties.

For the record, if you want to delete a key from a nested property, you don't need to use the customProperties property:
put the cProp of me into myPropArray
delete variable myPropArray["x"]
set the cProp of to myPropArray
but if you want to delete the property itself, here cProp, then you'll need the customProperties property.

Kind regards,

Mark

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Delete Custom Property

Post by [-hh] » Fri Aug 01, 2014 5:18 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:11 pm, edited 1 time in total.
shiftLock happens

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Delete Custom Property

Post by Mark » Fri Aug 01, 2014 5:22 pm

Hermann,

What do you mean with not-deleted?

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Delete Custom Property

Post by [-hh] » Fri Aug 01, 2014 5:33 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:11 pm, edited 1 time in total.
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: Delete Custom Property

Post by Da_Elf » Fri Aug 08, 2014 11:02 pm

supposed when i want to alter the custom properties of an item i want to delete all of the properties then store the new ones. however if something is wrong with the new ones to store i want to halt whats going on... then put the original properties back in. i can put te properties back in by using set customKeys of me to cks but how can i get a full array of the customkeys of the property and its value to save then put it back in (hope that made sense)

example of what i mean if i have some customKeys set with values in ButtonA and this script is run when ButtonB is clicked

Code: Select all

on mouseUp
   put the customkeys of button "ButtonA" into cks
   set the customKeys of the button "ButtonA" to empty
   answer "keep properties? " with "Yes" or "No" titled "Delete properties"
   if it = "Yes" then
      set customKeys of button "ButtonA" to cks
   end if
end mouseUp

Post Reply