Normal Topic PrinstStringC and PrintStringR (Read 3626 times)
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
PrinstStringC and PrintStringR
Apr 30th, 2007 at 3:10pm
Print Post Print Post  
Below are a set of subroutines that I wrote the other day for centering text when printed with PrintString and for right aligning text when printing with PrintString.

You would call these the same as you would the normal Printstring SBasic call the only difference is that for PrintStringC the X coordinate that you pass in is the X value for the text to be centered on and for PrintStringR the X Coordinate that you pass in is the X value for the text to right aligned against.

Code
Select All
Subroutine PrintStringC(vData as String, vCenterOn as Int, vY as Int, vWidth as Int, vFont as String, vSize as String, vMeasure as Int)
Var vMeasuredWidth as Int

	PrintString(vData, 0, 0, 0, vFont, vSize, 1)
	vMeasuredWidth = @PageExtentX()
	PrintString(vData, vCenterOn - (vMeasuredWidth/2), vY, 0, vFont, vSize, vMeasure)

End Subroutine 



Code
Select All
Subroutine PrintStringR(vData as String, vX as Int, vY as Int, vWidth as Int, vFont as String, vFontSize as Int, vMeasureOnly as Int)
Var vPrintedWidth as Int

	PrintString(vData, 0, vY, 0, vFont, vFontSize, 1)
	vPrintedWidth = @PageExtentX()
	PrintString(vData, vx - vPrintedWidth, vY, 0, vFont, vFontSize, vMeasureOnly)

End Subroutine 



-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: PrinstStringC and PrintStringR
Reply #1 - May 3rd, 2007 at 8:39pm
Print Post Print Post  
Thanks Ray, I'll make good use of that!
  

**
Captain Infinity
Back to top
IP Logged