Array key names
Posted: Mon Mar 08, 2010 2:58 am
What is the correct way to change the name of an array element? For example, how do I change myArray["xyz"] to be myArray["abc"].
Thanks,
Pete
Thanks,
Pete
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
command arrayKeyRename @xArray, pKeyName, pNewKeyName
local tKeyValue
put xArray[pKeyName] into tKeyValue
delete variable xArray[pKeyName]
put tKeyValue into xArray[pNewKeyName]
end arrayKeyRename
Code: Select all
on mouseUp
local tArray
put "test" into tArray["test1"]
arrayKeyRename tArray, "test1", "test2"
put tArray["test2"] --> test
end mouseUp