Normal Topic @LEN() and font size (Read 482 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
@LEN() and font size
Mar 28th, 2007 at 6:10pm
Print Post Print Post  
How does @LEN() relate to the Printstring() font size?  Does it relate at all?

Here's the problem I'm trying to solve:  I have a multi-line field on my Customer form that contains directions to the customer location.  It holds about 5 lines of text as displayed on the screen (but can contain more as the user keeps typing).  This data prints onto my Workorder form (paper form) into an area that is about 8 inches wide (Newpage is set at 850,1100), and about a half inch high.  The page extent and margins are set so it wraps nicely, and will hold about 4 lines of SanSerif text at a font size of 14 (small, but not too small to read, using my Epson dot-matrix printer).

I've been working on a subroutine that will measure the extent of the contents of the Directions field, compare it to a limit, warn the user if its too long for the Workorder, and throw him back into the field as he exits.  So far, I have this (borrowed code from someone's post or maybe Inside Sesame):
Code
Select All
GLOBAL CODE
// Checks the Directions length
Subroutine CheckDirLength(item as String)
sFont = "SanSerif"
sSize = 14
sAvailSpace = ???
PrintString(ThisElement, 0, 0, 0, sFont, sSize, 1)
If @PageExtentX() > sAvailSpace
	{
	@Msgbox("The Directions are too long for the Workorder.",
		"It is " + @PageExtentX() + " units long.",
		"The available space is " + sAvailSpace + ".")
	ThrowFocus(ThisElement)
	}
End Subroutine

DIRECTIONS :: on-element exit
// Checks the Directions length
CheckDirLength(ThisElement) 



The ??? is where I'm stumped.  If I fill the Directions field with text, @LEN() can count the characters, but I can't figure out how to relate that to Sanserif 14 at 8 inches with a four-line wrap.  Is there a rule-of-thumb for figuring this kind of thing out?  Is it just a matter of filling the field and grinding out multiple test prints to see where to cut it off?  Mixtures of capitals and lower case throw an extra wrinkle into the mix.

Any help would be appreciated.
  

**
Captain Infinity
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: @LEN() and font size
Reply #1 - Mar 28th, 2007 at 6:52pm
Print Post Print Post  
Hello Scott,

@Len will just return how many characters are in a string, not how much space they are going to take when printed.

Since you have the directions element wrapping onto 4 lines when printed(I assume you are setting a width on the printstring call) then you will want to be checking @PageExtentY() not @PageExtentX(). The PageExtentX() will return how wide it is, which since it wraps is not an issue. The issue will be if the printed data is too tall. So you compare @PageExtentY() to 50 (1/2 an inch with how you are specifying the NewPage)

The following is more along the lines of what you are looking for.

Code
Select All
GLOBAL CODE
// Checks the Directions length
Subroutine CheckDirLength(item as String)
sFont = "SanSerif"
sSize = 14
sAvailSpace = 50
NewPage(850, 1100)
PrintString(Item, 0, 0, 800, sFont, sSize, 1)
If @PageExtentY() > sAvailSpace
{
	@Msgbox("The Directions are too long for the Workorder.",
		"It will be " + @Str(@PageExtentY()) + " units tall when printed.",
		"The available space is " + @Str(sAvailSpace) + ".")
	ThrowFocus(ThisElement)
}
CancelPage()
End Subroutine

DIRECTIONS :: on-element exit
// Checks the Directions length
CheckDirLength(ThisElement)  



-Ray
  

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


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: @LEN() and font size
Reply #2 - Mar 28th, 2007 at 7:27pm
Print Post Print Post  
Thanks Ray, you've come through for me again.  I got so wrapped up in @PageExtentX() that I totally overlooked @PageExtentY().  You're the best!
  

**
Captain Infinity
Back to top
IP Logged