Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Using Print String to Produce Cheques (Read 2520 times)
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Using Print String to Produce Cheques
Jan 9th, 2006 at 10:24pm
Print Post Print Post  
Ray was kind enough to speak to me the other day regarding the sample cheque app in the Lantica library.

I was able to apply this and completely re-configure the cheque exactly to our specs, more or less.

A couple of issues though:

1. I need to make my amounts accept commas.  I have currently formatted them with two decimal places.

2. My amounts are left justified as they all have the same Y parameter.  I need them right justified similar to a report.

3. Lastly, I am using the convert numbers to words feature on the actual cheque.  Problem is if the words are too long they overlap my next field spec called date.

Is there a way to set a consistent specific length, and make it wrap to the next line ?

I tried setting up a Newline to move the last part of the words to a newline as follows but the "cents" are giving me a programming error:

vWords = vWords + @Newline(" and ") + Cents + "/100"

I would prefer to set up a max length though.

I can send the app to Ray if you like.

Thanks,

Louis
  

Louis Galvao
Back to top
 
IP Logged
 
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #1 - Jan 9th, 2006 at 10:46pm
Print Post Print Post  
Further issues I have encountered:

4. Where there are no values in a field, it is picking up 0.00 for number amounts and trying to pick up the @Left(,3) for date amounts even though there is no value there.

5. My command button is currently only printing the current record.  How would I go about programming it to deal with multiple records/cheques ?  I think Ray mentioned something about Mass Updating but I would prefer to program it so that a user can select records say with today's date and then print the current result set.

Thanks,

Louis
  

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


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Using Print String to Produce Cheques
Reply #2 - Jan 10th, 2006 at 3:29pm
Print Post Print Post  
Hello Louis,

1. You will need to re-write the FormatMoney() function in your Global Code section to insert the commas. Below is a Function that should do just that. Now it may have some problems in it, if it does just let me know

Code
Select All
Function FormatMoney(Val as Double) as String
Var vBack as String
Var vWhole as String
Var vFrac as String
Var vDub as Double

vWhole = @Str(@Int(Val))
vFrac = @Str(@Frac(Val)) + "00"
While @Len(vWhole) > 3
{
	vBack =  "," + @Right(vWhole, 3) + vBack
	vWhole = @Left(vWhole, @Len(vWhole) - 3)
}
vBack = vWhole + vBack

If @Instr(vFrac, ".") > 0 Then
{
	vDub = @ToNumber(vFrac)
	vFrac = @Str(@Decimals(@Round(vDub, 2), 2))
	vFrac = @Right(vFrac, 2)
}
vBack = "$" + vBack + "." + @Left(vFrac, 2)

Return vBack
End Function 



2. To Right Justify the values using Printstring you need to measure how long something is going to be when printed and then subtract that from where you want the right side of the money amounts to line up. Below is an excert from a larger routine that does just that.

Code
Select All
//RIGHT ALIGNING THE DOLLAR FIGURE
	vMoney = FormatMoney(Dollars)
//Measure how long the string will be when printed
	PrintString(vMoney, 0, 0, 0, "Arial", 16, 1)
	vSize = @PageExtentX()
//400 is the coordinate for the right edges to line up against
	vSize = 400 - vSize
//Print the actual value to the page
	PrintString(vMoney, vSize, vY, 0, "Arial", 16, 0) 



3. @Newline() does not take arguements so @Newline("And") is not going to work. If you want to truncate at a certain number of characters you can use @Left(). So
Code
Select All
@Left(vAmountText, 150) 

will return the first 150 characters and you can print that out. To break on the word "And" you would need to use @InStr() to find the position of "And" and then use @Left() and @Right() along with @Newline() to create a two line amount

4. The programming can only deal with the values that you pass it. If you pass it no values then it will try to deal with no values. In the example code in the SBasicCodeLibrary if you pass in a blank date you will get "January 0, 0", the formatted value of 0000/00/00 which is a blank date variable. If you pass in a blank amount you will get "$0.00" which is the formatted value of 0 which is a blank double variable.

Also the FormatDate() function that is in that example does not use @Left() it uses @Month$(), @DOM() and @Year() to format the date value.

5. To loop through your records use @ResultSetTotal() and @ResultSetCurrentPosition(). If you have a subform you will want to use @FormResultSetTotal() and @ResultSetCurrentPosition() to avoid any confusion as to which form you wish to operate on. The code below will loop through every record in the current result set.

Code
Select All
Var vLoop as Int
Var vCnt as Int

VLoop = 1
vCnt = @ResultSetTotal()

While vLoop <= vCnt
{
	ResultSetCurrentPosition(vLoop)
//Your code goes here and it will run on every record
	vLoop = vLoop + 1
}

ResultSetCurrentPosition(1) 



-Ray
  

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


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #3 - Jan 18th, 2006 at 8:08pm
Print Post Print Post  
Ray:

I am just working thru the info you provided me as follows:

1. Formatting Money for commas worked and I added a separate function called Format Commas to deal with amounts not requiring $ on the front of it

2. Right Justify - I am having some problems.  What I did is this in the Function PrintCheck:

I declared:    var vRJustify as Int
Defined it:     vRJustify = @PageExtentX()       
                         vRJustify = 675 - vRJustify

Called it:           PrintString(FormatCommas(vInv Amt),vRJustify, 150, 0, vFont, vSize, 0)

What is happening is it is still left aligning at X position 675.   There is reference to measuring the string in your code - is this what I am missing and how would I incorporate this into my example ?

3. @ Newline - I am taking the position to consistently wrap the words at the start of the "and....

     vWords = vWords + @Newline() + " and " + Cents + "/100"

4. Blank values in fields - can I not exclude this from printing by indicating some sort of argument or condition ?

5.  The loop to print multiple cheques worked like a charm.

Thanks,

Louis
  

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


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Using Print String to Produce Cheques
Reply #4 - Jan 18th, 2006 at 8:16pm
Print Post Print Post  
Quote:
2. Right Justify - I am having some problems.  What I did is this in the Function PrintCheck:

I declared:    var vRJustify as Int
Defined it:     vRJustify = @PageExtentX()       
                         vRJustify = 675 - vRJustify

Called it:           PrintString(FormatCommas(vInv Amt),vRJustify, 150, 0, vFont, vSize, 0)

What is happening is it is still left aligning at X position 675.   There is reference to measuring the string in your code - is this what I am missing and how would I incorporate this into my example ?


Yes that is what you are missing. It should be
Code
Select All
PrintString(FormatCommas(vInv Amt),0, 150, 0, vFont, vSize, 1)
vRJustify = @PageExtentX()
vRJustify = 675 - vRJustify
PrintString(FormatCommas(vInv Amt),vRJustify, 150, 0, vFont, vSize, 0) 



Quote:
4. Blank values in fields - can I not exclude this from printing by indicating some sort of argument or condition ?


Yes you can. What you need to do is put an If statement around the call to PrintCheck() so that PrintCheck() only gets called if certain fields are not blank.

Quote:
Thanks,

Louis


You are Welcome.

-Ray

-edited-
Error in posted code. Fixed for future reference.
« Last Edit: Jan 18th, 2006 at 10:19pm by Ray the Reaper »  

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


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #5 - Jan 18th, 2006 at 10:15pm
Print Post Print Post  
Ray:

One by one,  we (you) are taking care of business:

1.  Had a little more problems with the right justification but got it to work like this:

PrintString(FormatCommas(vInv Amt),0, 0, 0, vFont, vSize, 1)            
vRJustify = @PageExtentX()            
vRJustify = vJSize - vRJustify            
PrintString(FormatCommas(vInv Amt),vRJustify, 150, 0, vFont, vSize, 0)

Hats off to you for coming up with this !

2.  I will now concentrate on eliminating the blank values and let you know how I make out.

Just to give you an idea of my cheque setup:

- the top portion is the supplier stub reflecting details of up to 4 transactions
- middle portion is the actual cheque
- bottom portion is our copy reflecting full details and then some.

It is actually looking awesome right now.

Thanks,

Louis
  

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


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Using Print String to Produce Cheques
Reply #6 - Jan 18th, 2006 at 10:18pm
Print Post Print Post  
Quote:
1.  Had a little more problems with the right justification but got it to work like this:

PrintString(FormatCommas(vInv Amt),0, 0, 0, vFont, vSize, 1)            
vRJustify = @PageExtentX()            
vRJustify = vJSize - vRJustify            
PrintString(FormatCommas(vInv Amt),vRJustify, 150, 0, vFont, vSize, 0)

Hats off to you for coming up with this !


Yeah I was moving to fast and forgot to change the X Coordinate to 0 in your code. But as long as you got it figured out.

-Ray
  

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


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #7 - Jan 19th, 2006 at 5:48pm
Print Post Print Post  
Ray:

1. In dealing with the blank values, I placed the following code in the Function PrintCheck as follows:

     If vRef3 <> "" then
{
Printstring(...........)
}

This works great by eliminating the 0 values and I applied accordingly to deal with various fields.

2. My last issue is the wrapping of the wording of the cheque amount.

Currently I have used the following code to create a newline on every cheque at "and..."

vWords = vWords + @Newline() + " and " + Cents + "/100"

Works fine but looks funny on smaller cheques.

You mentioned truncating at a certain number of characters by using @Left.

What I would really like to do is break at a certain number and start a newline at the start of the next word (could be "and" or any word).

I will attempt the @Left/Right/Instr to see if I can get it to work.

Thanks,

Louis

  

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


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Using Print String to Produce Cheques
Reply #8 - Jan 19th, 2006 at 10:35pm
Print Post Print Post  
Hello Louis,

Have you tried setting a width to the PrintString() call that prints out the amount? The width is the 4th arguement. Assuming the NewPage is declared as 850, 1100, then if you type 400 in the width, the value will wrap at four inches or at closest space.

-Ray
  

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


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #9 - Jan 19th, 2006 at 10:40pm
Print Post Print Post  
Ray:

Funny you rang.

I just tried this piece of code to wrap:

vWords = @Left(vWords + " and " + Cents + "/100",55) + @Newline() + @Mid(vWords + " and " + Cents + "/100",56,56)

It wraps but cuts off part of one word and finishes off on next line.

How would I incorporate @INSTR in this statement to measure approximately 55 but cutoff at start of previous word (if that makes sense)

Thanks,

Louis
  

Louis Galvao
Back to top
 
IP Logged
 
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #10 - Jan 19th, 2006 at 10:48pm
Print Post Print Post  
Ray:

I replaced the previous code with the original:

vWords = vWords + " and " + Cents + "/100"

and change the width in the print string to 400 and it worked !

That just about does it !

Thanks for all your expertise.

I should send you this app to see the monster you created.

Thanks,

Louis
  

Louis Galvao
Back to top
 
IP Logged
 
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #11 - Jan 19th, 2006 at 11:09pm
Print Post Print Post  
Ray:

I ended up changing the width to 425 as 400 gave me a slight problem for some reason.

Also, when it does wrap, I have noticed that the first character on the second line is not in perfect alignment with the first line.  In two cases, it is just off a bit on the left.  Any reason that you can think of ?

Thanks,

Louis
  

Louis Galvao
Back to top
 
IP Logged
 
Louis Galvao
Full Member
***
Offline


"Sufferin' Succatash"

Posts: 265
Location: Canada
Joined: Feb 14th, 2005
Re: Using Print String to Produce Cheques
Reply #12 - Jan 23rd, 2006 at 10:15pm
Print Post Print Post  
Ray:

I am having a small issue with verifying a date field being blank so that it does not print off on my cheques.

I initially used the following code:

If vInvDate1 <> "" then
{
PrintString(vInvDate1,100, 175, 0, vFont, vSize, 0)
}

This returned a date Jan 0,0 in my cheque.

Then I tried this:

If @IsBlank(vInvDate1) then Clear(InvDate1) else
{
PrintString(vInvDate1,100, 175, 0, vFont, vSize, 0)
}

This cleared the contents even though there was information in one of my fields that I needed when I printed the cheque.

Then I tried this:

If NOT @IsBlank(vInvDate1) then
{
PrintString(vInvDate1,100, 175, 0, vFont, vSize, 0)
}

Again, this clearing all contents in the fields.

Is there another way around this ?

Thanks,

Louis
  

Louis Galvao
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Using Print String to Produce Cheques
Reply #13 - Jan 23rd, 2006 at 10:41pm
Print Post Print Post  
Quote:
If vInvDate1 <> "" then
{
PrintString(vInvDate1,100, 175, 0, vFont, vSize, 0)
}

This returned a date Jan 0,0 in my cheque.


Maybe you could use something similar to the following:

If vInvDate1 > @ToDate("1900/01/01") then
{
PrintString(vInvDate1,100, 175, 0, vFont, vSize, 0)
}
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Using Print String to Produce Cheques
Reply #14 - Jan 23rd, 2006 at 10:48pm
Print Post Print Post  
Hi Louis...

I recently submitted a concern about this issue. 

See http://www.lantica.com/Forum2/cgi-bin/yabb/YaBB.pl?board=gen_disc;action=display...
The default date is 0 for a blank date.  You will not get a date.

So you need to check to see if Date element = 0 vs. Blank.

Have not tested, but you might need to check for 0000/00/00 vs. 0.  Or check IF NOT Date< 1/1/1700 then .......... or something similar to that.

Hope this was helpful
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print