photools.com Community

IMatch Discussion Boards => General Discussion and Questions => Topic started by: Darius1968 on July 26, 2019, 08:20:14 AM

Title: Suppressing Display Of "Empty" Duration Values
Post by: Darius1968 on July 26, 2019, 08:20:14 AM
This is my code to display File Size (on Line 1) & File Duration (on Line 2), in the "Size" Column of my "Grid" File Window Layout: 

<TextBlock Grid.Column="0" Grid.Row="0" TextWrapping="Wrap" Margin="5,0,5,0"><Run FontSize="11pt"> {File.Size} </Run></TextBlock> <TextBlock Grid.Column="0" Grid.Row="1" TextWrapping="Wrap" Margin="5,0,5,0"><Run FontSize="11pt"> {File.Duration.HMS|is:Yes,{File.Duration.HMS} ;is:No, ;} </Run></TextBlock>

It works fine as it is, but what can I do to suppress "00:00:00", for the case of non audio/video files?  Thanks. 
Title: Re: Suppressing Display Of "Empty" Duration Values
Post by: Mario on July 26, 2019, 08:41:09 AM
You can simple do a numcomp to check if the duration is 0. Then either show some output or not

{File.Duration|cast:int;numcomp:ne,0,Has duration,Has no duration}

in your case probably

{File.Duration|cast:int;numcomp:ne,0,{File.Duration.HMS},}

This shows the duration only when it is not 0.

The cast:int is required because by default variables return numbers formatted based on the current user's numeric formatting settings.