Normal Topic Printing numbers with wordmerge (Read 1376 times)
PeterG
Member
*
Offline


No personal text

Posts: 11
Joined: Jan 19th, 2004
Printing numbers with wordmerge
Jan 31st, 2004 at 8:34pm
Print Post Print Post  
When I print numbers or currency with wordmerge, the numbers come out with 6 decimal places.  In Sesame the numbers are formatted with 0 deciimal places, but when the numbers are in the customer.txt file, they already have the extra decimal places, so it doesn't seem like it's a MS Word issue. Has anyone else found this or know how to correct it?
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Printing numbers with wordmerge
Reply #1 - Feb 1st, 2004 at 6:07pm
Print Post Print Post  
That is way the numbers and money fields are stored in database, as you correctly stated that the export file shows that value.

The work-around I am thinking is either to change the format of the element to text and you can still use them in calculation using Typecasting functions or making one more text element and merge that.  I think, the first choice is more practical.

You can  set it value using @Decimals (x, n) function, using n = 2 for currency and while merge add $ sign in front of it.
  
Back to top
 
IP Logged
 
PeterG
Member
*
Offline


No personal text

Posts: 11
Joined: Jan 19th, 2004
Re: Printing numbers with wordmerge
Reply #2 - Feb 2nd, 2004 at 12:23am
Print Post Print Post  
Bharat,

Thanks for the direction.  Could I trouble you for some more details, because I can't seem to get the converted text to calculate.  I have three text elements, QTY, PRICE, EXT PRICE What I need is for the QTY * PRICE = EXT PRICE, and for each money element  to have two decimal places, and the QTY to have no decimal places, when it gets printed (or viewed in TableView).  (Do you know of any plans to correct this in future releases, so we don't have to build the work around?)
Thanks for your help.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Printing numbers with wordmerge
Reply #3 - Feb 2nd, 2004 at 12:56am
Print Post Print Post  
Price is Money Field
Quantity is a Number field
Extend_Price is text field


The following Code goes in On Element Exit event in Quantiy field

Extended_Price = @str (Price * Quantity)
Extended_price = "$" + @decimals (Extended_Price, 2)

It seems to work perfectly well, so long you are taking extended_Price value in the wordmerge.

If you wish to take Price also in wordmerge, it will have to be changed accordingly.

Please let me know as to how does this works.




  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Printing numbers with wordmerge
Reply #4 - Feb 2nd, 2004 at 1:45am
Print Post Print Post  
If you need to wordmerge all namely,

Price
Quantity
Extended_Price

Format all of them as Text

following code goes in Price, element exit event

Price = "$" + @decimals (Price, 2)

Following code goes in Extended_Price element exit event

var vPrice as Double
var vQuantity as int

vPrice = @right (Price, (@len (Price) - 1))
vQuantity = @tonumber (Quantity)


Extended_Price = @str (vPrice * vQuantity)
Extended_price = "$" + @decimals (Extended_Price, 2)

Let me know how does this work.
  
Back to top
 
IP Logged
 
PeterG
Member
*
Offline


No personal text

Posts: 11
Joined: Jan 19th, 2004
Re: Printing numbers with wordmerge
Reply #5 - Feb 2nd, 2004 at 1:33pm
Print Post Print Post  
Bharat,

It's perfect!  Thanks.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Printing numbers with wordmerge
Reply #6 - Feb 2nd, 2004 at 1:48pm
Print Post Print Post  
Quote:
(Do you know of any plans to correct this in future releases, so we don't have to build the work around?)
Thanks for your help.


PeterG, I see why you want to have this to have permanent solution. For all caclulation involved, you have to keep on using typecast functions.

The way the value of number fields and Money Fields are stored is the Foundation blocks of Sesame. So do not expect to have any changes there.

In the wordmerge utility, value of Array elements can be changed when they are number or money format (with multiple 000000) also the date format nn/nn/nnnn can be manupulated at the array level before they are merged.

   
I believe a few lines of code in Wordmerge utility will do it (as I see the same correction codes have been included in the "Merge Printing Database Records Internally" in appendix 2).  However, I believe it should be done by the Sesame Development Team and included in the Wordmerge utility becasue this particular utility has become the essential part of Sesame for many for their printing needs. I hope, lanticans have been listening.
« Last Edit: Feb 2nd, 2004 at 9:06pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Alec
Lanticans
*****
Offline



Posts: 200
Location: Ascot, England, UK
Joined: Nov 22nd, 2002
Re: Printing numbers with wordmerge
Reply #7 - Feb 3rd, 2004 at 8:37pm
Print Post Print Post  
PeterG --

Take a look at the posting I've just put up: "Using MS-Word switches to format merge fields".  I think you'll find it's the answer to your number formatting problems.
  

Alec
Back to top
IP Logged