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

[-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] » Sat Aug 09, 2014 12:31 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:12 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 » Sat Aug 09, 2014 9:27 pm

that was a simplistic case. I guess i should have shown what i really wanted although the outcome is i still need to be able to save the customkeys and their values into an array then be able to put them back.
im not infront of my code to copy paste it so ill do this from memory (slightly downsized enough to get the point across)

on clicking an "update properties" button

Code: Select all

put the customkeys of button "ButtonA" into cks
set the customKeys of the button "ButtonA" to empty
put the label of field "propOptions"
switch propOptions
        case "video"
            put the text of field "videoname" into vidName
            if vidname is empty then
                  answer "You need to name the file"
            else
                  --put the customkeys and their values back
                  exit to top
            end if
            set cVidName of the button "ButtonA" to vidName
            break
        case "audio"
            put the text of field "audioname" into audName
            if audNameis empty then
                  answer "You need to name the file"
            else
                  --put the customkeys and their values back
                  exit to top
            end if
            set cAudName of the button "ButtonA" to audName
            break
    end switch
this way if you wanted to change the button from having video options in it to having audio options in it the script will save the custom properties, delete the buttons properties. then put the new ones in. If however something goes wrong like forgetting to put in a correct value then it can put the original properties back. show an error then exit the script.

im guessing i might have to use a repeat loop to create my own array and there is no shortcut to do this

[-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] » Sun Aug 10, 2014 11:06 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:12 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 » Sun Aug 10, 2014 12:35 pm

deleting the properties is about being neat. Like i said i made this code smaller to type it out. each option (yup. i meant option button not field opps) will contain roughly 10-20 custom properties. If i was going to change from audio to video then i dont want 20 video properties lingering around. I want to flush out all the properties and then add the new ones. So i see from your code that there is infact no simple way to save the customKeys and their values into an array
ok so in sifting through your code the only thing i really needed is this it seems

Code: Select all

command resetKeys bName,fArr
   put the keys of fArr into fks
   sort fks
   repeat for each line k in fks
      set k of btn bName to fArr[k]
   end repeat
end resetKeys

on mouseUp
   put the customProperties of btn "ButtonA" into myProp
   set the customProperties of the button "ButtonA" to empty
   answer "keep properties? " with "Yes" or "No" titled "Delete properties"
   if it = "Yes" then
      resetKeys "ButtonA",myProp
   end if
end mouseUp

[-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] » Sun Aug 10, 2014 2:35 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 4:12 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 » Sun Aug 10, 2014 3:40 pm

in the way i was thinking i was trying to save code. The user has made a choice to change a button from being a video button with a bunch of custom attributes dealing with video to being an audio button with a whole bunch of totally different attributes. When he fills out the form for it to become an audio button using switch case it now has to check all of these attributes to see if everything is correct. since each case is totally different depending on video or audio switch case seems the best method. if all is ok as defined by that case then enter the new properties. The old ones i dont want in there any more and it would be more confusion to weed them out. the best option seemed to be to save the original attributes, then wipe the slate clean, then do my check to see if all is ok and if not i can always take a step backwards and put the button back to how it was before. technically if they have made the choice to switch from video to audio then they should make sure to have all the correct fields filled in and who cares about the deleted video properties.

Post Reply