Difference between revisions of "$bytes"

From Scriptwiki
Jump to: navigation, search
($bytes)
 
Line 1: Line 1:
 
Returns comma formatted filesize.
 
Returns comma formatted filesize.
  
  $bytes(''N'',bkmgt3).suf
+
  $bytes(''N'',bkmgt3)[.suf]
The '''bkmgt''' options return the result as bytes, kilobytes, megabytes, gigabytes or tegabytes.<br>
+
The '''bkmgt''' options return the result as bytes, kilobytes, megabytes, gigabytes or terabytes.
Using option '''3''' would return is the best human readable style and is the default option.<br>
+
 
 +
Using option '''3''' would return is the best human readable style and is the default option.
 +
 
 
The ''suf'' property appends B,KB,MB,GB or TG depending on what formatting is being used.
 
The ''suf'' property appends B,KB,MB,GB or TG depending on what formatting is being used.
 
== Examples ==
 
== Examples ==
Line 9: Line 11:
 
  echo -ag $bytes(123456,m)  ;Returns ''0.12'' because there is 0.12 megabytes in ''123456'' bytes
 
  echo -ag $bytes(123456,m)  ;Returns ''0.12'' because there is 0.12 megabytes in ''123456'' bytes
  
  echo -ag $bytes([[$file]]([[$sfile]]([[$mircdir]])).size).suf ;Returns the size of the file you selected in the best human readable form with its suffix appended.
+
  echo -ag $bytes([[$file]]([[$sfile]]([[$mircdir]])).size).suf
 +
Returns the size of the file you selected in the best human readable form with its suffix appended.
 +
 
 +
echo -ag [[$replace]]($bytes(1000000),[[$chr]](44),.)
 +
Returns the number spezified as $bytes parameter in following form: "1.000.000".
 
[[Category:Text and Number Identifiers]]
 
[[Category:Text and Number Identifiers]]

Revision as of 17:47, 12 October 2005

Returns comma formatted filesize.

$bytes(N,bkmgt3)[.suf]

The bkmgt options return the result as bytes, kilobytes, megabytes, gigabytes or terabytes.

Using option 3 would return is the best human readable style and is the default option.

The suf property appends B,KB,MB,GB or TG depending on what formatting is being used.

Examples

echo -ag $bytes(1024,k)  ;Returns 1 because there is 1 kilobyte in 1024 bytes
echo -ag $bytes(123456,m)  ;Returns 0.12 because there is 0.12 megabytes in 123456 bytes
echo -ag $bytes($file($sfile($mircdir)).size).suf

Returns the size of the file you selected in the best human readable form with its suffix appended.

echo -ag $replace($bytes(1000000),$chr(44),.)

Returns the number spezified as $bytes parameter in following form: "1.000.000".