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.

zeros in decimal numbers in a variable... how to keep them?

Featured Replies

I'm generating a report in which the script goes through several records one at a time and sets a variable to contain values from multiple fields in each record (separated by tab characters usually). Most of the fields are text. But one is an 'amount' field which should look like 3.50 or .90 or 3.00, etc. So the zeros are important.

At the end of the script, the variable is dumped into a field.

Problem: the contents of the "amount" fields show as 3.5, .9 or 3 instead of 3.50, .90 or 3.00.

I tried using SetPrecision() but no change.

Apparently, the field's number format is not going into the variable along w/the field value.... either that or the fact that the variable stores both text and numbers, it's taking it all as text?

(I guess, now that I think about it, I'm not 100% sure they are going into the variable without the formatting... it could be happening when the variable is dumped in the field?)

In any case, how might I get these numerical values to look right in a big text field with alot of other stuff?

Code snippet

Set Variable...

$rptitems&¶

&Globals::gTab &Item::Number&Globals::gTab & Item::Date&Globals::gTab

&Payee::PayeeName&Globals::gTab&Item::Memo&Globals::gTab&SetPrecision(Item::Amount;2)

SetPrecision() does something else. See if this helps:

http://fmforums.com/forum/topic/73150-rounding-a-calculation-field/page__p__345958#entry345958

  • Author

SetPrecision() does something else. See if this helps:

http://fmforums.com/forum/topic/73150-rounding-a-calculation-field/page__p__345958#entry345958

Thanks... I see the problem. The calculation result that sets the variable is text. The answer might be in the thread you linked to, but I'm not (yet) understanding it. Will have to do some more reading.

Edit: problem is that these are usually negative numbers but also occasionally positive ones

  • Author

Got it!

Case(PatternCount(Item::Amount;".")=0;Item::Amount&".00";

PatternCount(Right(Item::Amount;2);".")=1;Item::Amount&"0";

Item::Amount)

That will work too - if you're happy with ".25" instead of "0.25".

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.