Byte Converter ( )

Function stats

Average user rating
164
211
9999
Support
FileMaker 7.0 +
Date posted
09 March 2009
Last updated
09 March 2009
Version
Recursive function
No

Author Info
 Delta Tango

2 functions

Average Rating None

author_avatar



 

Function overview

Prototype

Byte Converter  ( bytes )


Parameters

bytes  


Description

Tags:  byte converter, byte, file size, bit converter  

This function will takes a integer of a number of bytes fed to it and turn it into a readable human format. Fixed the output.

Examples

Sample input

1678480


Sample output

1.68 MB

 

Function code

Let(
[
$symbols = "B¶KB¶MB¶GB¶TB¶PB";
$exp = If(bytes; Floor(Log(bytes) / Log(1024)) ; 0)
];

Round( (bytes / 1024^Floor($exp)) ; 2) & " " & GetValue ( $symbols ; $exp + 1)

)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/211

    Prototype: Byte Converter( bytes )
    Function Author: Delta Tango (http://www.fmfunctions.com/mid/164)
    Last updated: 09 March 2009
    Version: 1.1

*/
// ===================================

 

Comments

Robert Schaub
09 March 2009



in your example , if round 2 , should your results be 1.68 MB?
  General comment
Delta Tango
09 March 2009



Yes, that is what I entered but for some reason when I enter 1.68, it changes it to 1.6.
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (30)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)