Jump to content

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


This topic is 4404 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 4404 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

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