ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Print functions
  • Origin and physical margins
  • Managing the parameter
  • Combining positions ( parameter)
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Controls the horizontal position (abscissa or column) of the print cursor on the page. You can:
  • find out the current horizontal position,
  • modify the horizontal position of print cursor.
Note When printing a text string, the current vertical position points to the top of the string to be printed. The bottom print line depends on the height of the fonts used in the printed line.
Example
// Traçage de traits verticaux séparés de deux millimètres
// sur toute la largeur de la page
iVLine(0, iPageHeight(), 1) // Trace un trait
iXPos(iXPos() + 2)   // Décale de 2
iVLine(0, iPageHeight(), 3) // Trace un trait
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 when printing (when nesting positions for example). For more details, see remarks.
Remarks

Origin and physical margins

The origin (0,0) is located in the upper-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
sMonTitre is string = "Titre impression" 
iDestination(iViewer)
// --- CAS 1 : <Calcul immédiat> à Vrai (par défaut)
// Positionnement du curseur à l'endroit souhaité
// Note : La chaîne de caractères de contrôle n'est pas récupérée ici
iXPos((iPageWidth() - iTextWidth(sMonTitre))/2) 
// Calcul pour centrer le texte

// Impression à la position du curseur précédemment déterminée
iPrint(sMonTitre)	// Donc doit être centré
// --- CAS 2 : Le même code avec le paramètre <Calcul immédiat> à Faux
// La chaîne de caractères de contrôle n'est pas récupérée ici
// Et le curseur d'impression n'est pas positionné car 
// <Calcul immédiat> est à Faux
// Note : Donc cette ligne ne sert à rien
iXPos((iPageWidth() - iTextWidth(sMonTitre))/2, False)

// Impression à la position du curseur
// La ligne de code précédente ne l'ayant pas changé 
// le texte va s'imprimer à la position précédente (donc en début de ligne ici)
iPrint(sMonTitre)	//Donc NE doit PAS être centré
// --- CAS 3 : Le code en une seule ligne
// Avec le paramètre <Calcul immédiat> à Faux ou à Vrai
// le résultat est le même

// La position du curseur d'impression est modifiée au moment de 
// l'exécution de iPosX, et au moment de l'impression de la 
// chaîne de caractères qui contient le résultat renvoyé par iPosX
iPrint(iXPos((iPageWidth() - iTextWidth(sMonTitre))/2, True) + sMonTitre) 
// Donc doit être centré
// Le positionnement est fait deux fois : un peu plus lourd
// mais le résultat est celui attendu
// --- CAS 3 Bis
// La position du curseur d'impression N'est PAS modifiée au moment
// de l'exécution de iPosX, MAIS elle est modifiée au moment
// de l'impression de la chaîne de caractères qui contient le résultat
// renvoyé par iPosX
iPrint(iXPos((iPageWidth() - iTextWidth(sMonTitre))/2, False) + sMonTitre)
// Donc doit être centré
// Fin d'impression 
iEndPrinting()

Combining positions (<Immediate Calculation> parameter)

When combining positions, unexpected results may occur. For example, the following code:
iXPos(50)
iPrint("Première partie" + iXPos(20) + "Seconde partie")
is not equivalent to:
iPrint(iXPos(50) + "Première partie" + iXPos(20) + "Seconde partie")
In the first case, the entire character string is printed at horizontal position 20. In this case, iXPos(20) is run when the string is built, before the "First Part" string is printed.
To obtain the same result, simply use the function iXPos with the parameter False parameter: the iXPos(20, False) function will only really be executed during printing.
The same operation can be performed by iYPos.
Component: wd300prn.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help