Page 1 of 1
Setup / modify custom column definitions via scripting
Posted: 22 Mar 2019 00:38
by highend
It would be a great addition if we'd be able to setup and modify custom columns via a script command on the fly.
E.g.:
Code: Select all
EditCustomColumn("ID", "Caption", "Type", "Property/Template/Script/Mixed", "[Format=Text]", "[Trigger=Browse]", "[ItemType=Files]", "[Item filter]");
Re: Setup / modify custom column definitions via scripting
Posted: 22 Mar 2019 09:12
by highend
Using "" for a parameter would clear it (e.g. for "[Item filter]")
and the function should return the current cc setup for an id e.g. via
$data = EditCustomColumn("ID");
Why the whole fuss?
Because you could do such things on the fly:
Code: Select all
$rules = <<<'>>>'
Year=<cc_base><:>^([a-z]+_)(\d{4})(.*)$<:>$2
Month=<cc_base><:>^([a-z]+_\d{4})(\d{2})(.*)$<:>$2
Day=<cc_base><:>^([a-z]+_\d{4}\d{2})(\d{2})(.*)$<:>$2
>>>;
$index = inputselect("Choose your rule...", regexreplace($rules, "^(.*?)=(.*?)$", "$1"), <crlf>, 32+64+128, , 300, 300);
$rule = gettoken($rules, $index, <crlf>);
$caption = gettoken($rule, 1, "=");
$condition = gettoken($rule, 2, "=");
$onWhat = gettoken($condition, 1, "<:>");
$pattern = gettoken($condition, 2, "<:>");
$replaceWith = gettoken($condition, 3, "<:>");
$script = <<<>>>
return regexreplace($onWhat, "$pattern", "$replaceWith");
>>>;
EditCustomColumn("14", "Sort by $caption", "Script", $script);