PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Origin and physical margins
  • Managing the parameter
  • Combining positions ( parameter)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Allows you to manage the horizontal position (X coordinate) of print cursor in the page. You can:
  • find out the current horizontal position,
  • modify the horizontal position of print cursor.
Note: When printing a character string, the current vertical position points to the top of the string to print. The bottom print line depends on the height of the fonts used in the printed line.
Example
// Draw vertical lines separated by two millimeters
// across the entire page width
iVLine(0, iPageHeight(), 1) // Draws a line
iXPos(iXPos() + 2)  // Shifts  by 2
iVLine(0, iPageHeight(), 3) // Draws a line
iEndPrinting()
Syntax

Finding out the horizontal position of print cursor Hide the details

<Result> = iXPos()
<Result>: Real
Current horizontal position of cursor (in millimeters).

Modifying the horizontal position of print cursor Hide the details

<Result> = iXPos(<Horizontal position> [, <Immediate Calculation>])
<Result>: Character string
Requested horizontal position.
<Horizontal position>: Real
New horizontal position (X coordinate) of print cursor (in millimeters).
<Immediate Calculation>: Optional boolean
  • True (by default) to immediately calculate the horizontal position.
  • False if the horizontal position must be calculated during the print (when nesting positions for example). See remarks for more details.
Remarks

Origin and physical margins

The origin (0,0) is located in the top left corner of the sheet. This origin takes the physical printer margins into account.
Each printer includes physical margins in which no printing is possible. iMargin is used to define the "logical" print margins. If logical margins have been defined, iXPos manages the horizontal position according to these new margins.

Managing the <Immediate Calculation> parameter

When <Horizontal Position> is specified in iXPos, the function performs two actions at the same time:
  • Returns a control character string. This control character string modifies the print position when the string is printed.
  • Immediately modifies the position of print cursor
The <Immediate Calculation> parameter is used to retrieve the control character string without modifying the current position of print cursor
sMyTitle is string = "Print title"
iPreview()
// --- CASE 1: <Immediate Calculation> is set to True (default)
// Position the cursor at requested location
// Note: The control character string is not retrieved here
iXPos((iPageWidth() - iTextWidth(sMyTitle))/2)
// Calculation to center the text
 
// Print at cursor position (defined beforehand)
iPrint(sMyTitle)      // Must be centered
// --- CASE 2: The same code with <Immediate Calculation> set to False
// The control character string is not retrieved here
// And the print cursor is not positioned because
// <Immediate Calculation> is set to False
// Note: Therefore, this line is not required
iXPos((iPageWidth() - iTextWidth(sMyTitle))/2, False)
 
// Print at cursor position
// As the previous code line did not change it
// the text will be printed at the previous position (at the beginning of line)
iPrint(sMyTitle) //Therefore MUST NOT be centered
// --- CASE 3: A single code line
// With <Immediate Calculation> set to True or to False
// the result is the same
 
// The position of the print cursor is modified when
// running iXPos, and when printing the
// character string that contains the result returned by iXPos
iPrint(iXPos((iPageWidth() - iTextWidth(sMyTitle))/2, True) + sMyTitle)
// Must be centered
// The positioning is done twice: a little bit longer
// but the result is the expected one
// --- CASE 3 B
// The position of print cursor IS NOT modified when
// running iXPos, BUT it is modified when
// printing the character string that contains the result
// returned by iXPos
iPrint(iXPos((iPageWidth() - iTextWidth(sMyTitle))/2, False) + sMyTitle)
// Must be centered
// End of print
iEndPrinting()

Combining positions (<Immediate Calculation> parameter)

When combining positions, unexpected results may occur. For example, the following code:
iXPos(50)
iPrint("First part" + iXPos(20) + "Second part")
is not equivalent to:
iPrint(iXPos(50) + "First part" + iXPos(20) + "Second part")
In the first case, the entire character string is printed at horizontal position 20. Indeed, in this case, iXPos(20) is run when building the string to print and therefore before the "First Part" string is printed.
To get an identical result, all you have to do is use iXPos with the False parameter: iXPos(20, False) will only be run during the print.
The same operation can be performed by iYPos.
Component : wd240prn.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment