• Call: 1-877-612-9320
  • Email: info@foxtailtech.com

FileMaker Custom Function - Format Bytes

Post Details

I recently had a need to format a field that was logging bytes into a database of files.

The custom function has two (2) dependancies:

1.) MinValue ( theList; treatAsNumeric )
URL: http://www.briandunning.com/cf/1566

2.) MaxValue (theList; treatAsNumeric )
URL: http://www.briandunning.com/cf/1565

Custom Function:

formatBytes ( bytes; precision )

Let ([
units = “B¶KB¶MB¶GB¶TB¶PB¶EB¶ZB¶YB”;
newBytes = MaxValue ( bytes & “¶0”; 1);
pow = Floor ( If ( newBytes; Ln ( newBytes ) / Ln ( 1024 ); 0 ) );
selUnit = MinValue ( pow & “¶” & (ValueCount ( units ) -1 ); 1);
result = newBytes / (1024^selUnit)
];
Round ( result ; precision ) & “ ” & GetValue ( units ; selUnit + 1 )
)

This function will take a byte value and convert it to the appropriate order of magnitude, while selecting the byte value.

  • Mon, Mar 7th, 08:50
  • closed
  • FileMaker Custom Function

Categories

Recent News

Announcement! Backups to...

We are proud to announce that your backups can now be synchronized with...

Warning! Update Mozilla...

Earlier this week, Mozilla Security researcher Cody Crews, discovered a malicious...

Another OpenSSL High...

An update to the widely used OpenSSL crypto library will come out Thursday, July...