Normal Topic Dollar conversion in word document (Read 1200 times)
wildwood
Full Member
***
Offline


No personal text

Posts: 156
Location: New York
Joined: Apr 2nd, 2004
Dollar conversion in word document
Nov 3rd, 2007 at 8:14pm
Print Post Print Post  
I have a word-merge document which has been perfect, in Sesame 1.x, as far as converting dates and money amounts in Word (2007). In version 2.x I get the following: 850.0000 instead of $850.00. The date conversion into Sesame 2.x has not been a problem. Why the difficulty in the newer version and how do I correct it?

Peter
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Dollar conversion in word document
Reply #1 - Nov 3rd, 2007 at 10:16pm
Print Post Print Post  
The correction depends on how you are formatting the value? Are you formatting in Sesame or are you using a Word field switch? If in Sesame, please post the SBasic you are using to format the money value.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wildwood
Full Member
***
Offline


No personal text

Posts: 156
Location: New York
Joined: Apr 2nd, 2004
Re: Dollar conversion in word document
Reply #2 - Nov 4th, 2007 at 3:15pm
Print Post Print Post  
Hi Erika,
Below is the code installed in the Global Code area.
I don't know if this is what you were asking for but it is the same as I used in 1.0x and it worked perfectly there.

Peter

// These GLOBAL CODE User Defined Functions are used by the
// WordMerge Lite program attached to 'Merge Print' button.
// They can be moved from here into that program
// if located just before the first subroutine.

FUNCTION FD(theDate as Date) as String

// FD function Converts Date values in fields
// or variables from the internal 'YYYY/MM/DD'
// format to readable 'Month Day, Year' format

var stringDate as String = @Mid(theDate,6,2) +
"/" + @Rt(theDate,2) + "/" + @Left(theDate,4)

return stringDate

END FUNCTION


FUNCTION FT(t as Time) as String

// Formats time values in '4:55 pm' style
// as opposed to raw time value '16:55'
// Doesn't do seconds.

// Calling syntax: FT(timevalue)
// Example: FT(QuittinTime)

var tf as String      //time formatted
var Hr as Int            //hour of day
var Min as String      //minutes
var ampm as String      //am or pm

tf = @Str(t)
Hr = Split(tf, ":")
Min = tf

If Hr > 0 and Hr < 12 { ampm = " am" }
Else If Hr > 12 { Hr -= 12; ampm = " pm" }
Else If Hr = 0 { Hr = 12; ampm = " am" }
Else {ampm = " pm" }

Return Hr + ":" + Min + ampm

END FUNCTION

FUNCTION FNM(NMVal as Double, decs as Int, sep as String, sign as String ) as String
/*
Formats Number & Money values - TJM 11/15/05
decs: number of decimal places
sep: 1000's separator character in quotes
sign: currency sign in quotes

Call syntax: FNM(moneyval, decs, seps, sign)
Ex: FNM(Amount, 2, ",", "$") = 2 dec. places, commas, $ sign
Ex: FNM(Amount, 3, "", "") = 3 dec. places, no sep, no money sign
*/

var intPart as String      //integer part of passed value
var decPart as String      //decimal part of passed value
var endPart as String      //processing (3-digit group) var
var result as String      //processing result var
var val as String      //NMVal to String
var n as Int            //loop counter
var na as String      //negative amount

val = @Decimals(NMVal, decs)

intPart = @Int(val)
If @In(val, ".") > 0 { decPart = @Md(val, @In(val, "."), 6) }

If @TN(intPart) < 0
{ na = "-"; intPart = @Abs(intPart) }

For n = @Len(intPart) downto 1 step 3
   endPart = sep + @Rt(intPart, 3)
   intPart = @Lt(intPart, @Len(intPart) -3)
   result = endPart + result
Next

If @Asc(result) < 48
{ return na + sign + @Replfir(result, sep, "") + decPart }
Else
{ return na + sign + result + decPart }

End Function

Function FBool(vBool as Boolean) as String

If vBool = 1 Then
return "Yes"
Else
return "No"

End Function

Function FImg(vPath as String, w as Int, h as Int) as String
var vImg as String
vImg = "<img border='0' src='file:///" + vPath + "' width='" + w + "' height='" + h + "'>"
return vImg
End Function

  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Dollar conversion in word document
Reply #3 - Nov 4th, 2007 at 3:25pm
Print Post Print Post  
wildwood wrote on Nov 4th, 2007 at 3:15pm:
Hi Erika,
Below is the code installed in the Global Code area.
I don't know if this is what you were asking for but it is the same as I used in 1.0x and it worked perfectly there.


Peter,

Between 1.x and 2.0, Money was changed over to fixed point. Somewhere in your code is a bit that expects 6 decimal places where there are now only 4. I'm afraid I can't look for it right now. One of us will get it tomorrow, if you don't find it yourself.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Dollar conversion in word document
Reply #4 - Nov 5th, 2007 at 2:46pm
Print Post Print Post  
Hello Peter,

In your programming for the Word merge button you will have a line that looks similiar to the following

Code
Select All
If nn = 5 Then vVal = FNM(vVal, 2, ",", "$") 



You will need to change it to

Code
Select All
If nn = 19 Then vVal = FNM(vVal, 2, ",", "$") 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
wildwood
Full Member
***
Offline


No personal text

Posts: 156
Location: New York
Joined: Apr 2nd, 2004
Re: Dollar conversion in word document
Reply #5 - Nov 5th, 2007 at 6:58pm
Print Post Print Post  
Ray,
Thank You!

Perhaps a little explanation on why the change from 

If nn = 5 Then vVal = FNM(vVal, 2, ",", "$") to
If nn = 19 Then vVal = FNM(vVal, 2, ",", "$")

makes the Merge Print work in version 2.x

Peter
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Dollar conversion in word document
Reply #6 - Nov 5th, 2007 at 7:06pm
Print Post Print Post  
The type of money fields was represented a 5 in 1.X and is now represented by a 19 in 2.x as the Money type itself is different. You just had to change the code so that it was using the right number that signifies Money.

If you get Inside Sesame, I let Tom know about this a little while back and he wrote up a little tidbit about it in the October issue.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged