Professional Software Development for FileMaker®



FileMaker 8 Certified Developer
FileMaker 10 Certified Developer
FileMaker Business Alliance
FileMaker Technical Network
SUI Solutions is an independent entity and this web site has not been authorized, sponsored, or otherwise approved by FileMaker, Inc.

GetContainerSize

Filemaker custom function that returns container size in bytes, kilobytes or megabytes with the corresponding abbreviation.

Format

GetContainerSize ( Container ; Precision )

Parameter

Container - any container expression or container field

Precision - number of decimal places, any numeric expression or field containing a numeric expression

Data type returned

text

Description

Returns size (always more than 1 if not empty) of Container in bytes, kilobytes or megabytes with the corresponding abbreviation (B, KB or MB), rounded to the specified number of decimal places.

Example 1

Input:

GetContainerSize ( Files::file1 ; 0)

Output:

213 B

Example 2

Input:

GetContainerSize ( Files::file2 ; 1)

Output:

72.6 KB

Example 3

Input:

GetContainerSize ( Files::file3 ; 2)

Output:

5.63 MB

Source code

Select all
Let (
    cSize = Length ( Container );
    Case(
        cSize ≥ 1048576; Round ( cSize/1048576 ; Precision ) & " MB";
        cSize ≥ 1024; Round ( cSize/1024 ; Precision ) & " KB";
        cSize > 0; cSize & " B";
    )
)