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.
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
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