SetColumns can get you the column width in pixels, allowing you to adjust what is returned based on that width. You'll need to play around a bit to figure out how the pixel width relates to your desired output lengths but that'll just take a little bit of trial and error.
This will not automatically adjust to resizing the column - and likely never will because it would mean triggering the script repeatedly during the resizing - but you can force the column to refresh after changing the column width to have it take on the new format. (Right-Click > Refresh Column or just refresh the list with F5, etc.)
Code: Select all
function GetColumnWidth($column) {
return GetToken(FormatList(SetColumns(,2),'f', ',', "$column.*"), 2, '.',, 2);
}
// This needs to be the name that XY uses to identify the column.
// For Custom Columns that is 'Custom #'.
$width = GetColumnWidth('Custom 3');
if ($width < 40) {
$fmt = 'yyyy';
} elseif ($width < 60) {
$fmt = 'yyyy.mm';
} elseif ($width < 100) {
$fmt = 'yyyy.mm.dd';
} else {
$fmt = 'yyyy.mm.dd hh:nn:ss';
}
return Report("{Modified $fmt}", <cc_item>);
XYplorer Beta Club