How is this supposed to work? Using licensed 4.0.0.2 ULT x64 2018-05-21.
The goal: for certain log files, display the number of log entries in the file. For other files, display blank or Size [S] - don't really care. Assume the relevant log files are 1,000 bytes or larger, with sizes in multiples of 100. Each log entry is 100 bytes long (99 bytes of visible data plus line-terminator). As a result, the file size is always [number of lines] multiplied by 100.
Ideally, the formula would be ${Size} / 100, but that did not work. As a workaround, try: convert ${Size} to a string, and drop the trailing two zeros. Go ahead and skip files whose size-strings are shorter than four digits (the thousands separator does not exist in this problem domain).
So this works:
Code: Select all
# for file sizes > 999 bytes, convert Size to a string and return substring: from the first character, to the end, except for the last-one character.
# for file sizes <= 999 bytes, return the actual Size
if ( ${Size} > 999
,mid( str( ${Size} ), 1, len( str( ${Size} ) ) - 1 )
, ${Size}
)
The relevant files appear as one-tenth their size. We want them to appear as one one-hundredth of their size, so, drop one more zero, but this fails:
Code: Select all
# for file sizes > 999 bytes, convert Size to a string and return substring: from the first character, to the end, except for the last-*two* characters.
# for file sizes <= 999 bytes, return the actual Size
if ( ${Size} > 999
,mid( str( ${Size} ), 1, len( str( ${Size} ) ) - 2 )
, ${Size}
)
The error message is "Syntax error: wrong function argument", with the formula re-rendered as
Code: Select all
if(${Size}>999,mid(str(${Size}),1,len(str(${Size}))-2),${Size})
and the second 'len' highlighted/selected. Wha? Experimenting shows that this
gives correct-looking results; same with subtracting 1 or 2 instead of 0.