I changed both forms of remove_property to return the previous value of the property.
string remove_property( string name )
If its a built-in property, resets to default.
Otherwise, removes from the user map.
In either case, return the old value
string remove_property( string name, boolean global )
If its a built-in property, resets to default.
Otherwise, removes from the specified map.
In either case, return the old value
Given that, the following works to migrate a user property from one name to another.
Unfortunately, since, as I mentioned, set_property() logs changes to the gCLI, this prints something.
I'm considering making that into a built-in function:
boolean rename_property( string old_name, string new_name )
string remove_property( string name )
If its a built-in property, resets to default.
Otherwise, removes from the user map.
In either case, return the old value
string remove_property( string name, boolean global )
If its a built-in property, resets to default.
Otherwise, removes from the specified map.
In either case, return the old value
Given that, the following works to migrate a user property from one name to another.
Code:
boolean migrate_property( string old_name, string new_name )
{
if ( !property_has_default( old_name ) &&
!property_has_default( new_name ) &&
property_exists( old_name, false ) &&
!property_exists( new_name, false ) ) {
set_property( new_name, remove_property( old_name ) );
return true;
}
return false;
}
I'm considering making that into a built-in function:
boolean rename_property( string old_name, string new_name )