Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Converting KB,MB,GB to readable numbers

Featured Replies

In my DB I have a text file which tells me the size of audio and video clips as such 

927 KB or 1020 KB

and

27.5 MB or 15.26 MB

and 

2.01 GB or 11,3 GB

 

I used the following suggestion from this forum:

Mediasize::MediaSize * If ( PatternCount ( Convert Mediasize::MediaSize ; "GB" ) ; 1024 ; 1 )

but while it works fine with GB it doesnt work with MB or KB

Instead of doing a script a did a calculation as such

Case ( PatternCount ( Convert Mediasize::MediaSize ; "GB" ) ; Convert Mediasize::MediaSize* 1024; PatternCount ( Convert Mediasize::MediaSize ; "KB" ) ;  Left ( Convert Mediasize::MediaSize ; Length ( Convert Mediasize::MediaSize )  - 3) /1024^2  ; PatternCount ( Convert Mediasize::MediaSize ; "MB" ) ; "0,00" &  Substitute ( Left ( Convert Mediasize::MediaSize ; Length ( Convert Mediasize::MediaSize )  - 3) ; "." ; "" ) )

I used the Substitute function as in my country we use commas for decimals

however while the calculation works I get really large numbers for KB files and MB files

Is there a different way to calculate the text files to get regular number with perhaps a maximum of 3 decimals?

I could use it as a script or as a calculation defining the field

Thanks a lot and regards

  • Author

Thanks for your interes and time. But .... How do I add it as a custom function to my FMPADV 13?

If I use it as a calculation or script FMP tells me it cannot find various fields and I am totally lost

Thanks again 

 

Refer to this.

  • Author

Thanks for your interest however even following step by step I am unable to create the external function

After I paste in New external function the code FMPADV 13 tells me I need to enter the function for:

 

 Floor ( Ln ( bytes ) / Ln ( _ratio ) ) 

It selects the word bytes and I am unable to continue as I am not skilled enough to do it 

Even if some kind person will help to find the "bytes" I am afraid I will run into some similar or different tasks which I won't know how to solve.

Thanks however

Dan

 

 

Edited by dkey

While you're editing the custom function, you need to set what the parameters are before the calculation will recognize the "bytes" and "precision" tokens, which would be undefined otherwise.

Screen Shot 2017-11-16 at 09.35.31.png

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.