Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

POS

Keyword Abbreviation Token (hex) Version(s) Classification
POS none B9 1.0+ Function

  Syntax  
POS dummy )
 
Parameters Type Legal Value(s) Note(s)
dummy Numeric
any
 
Returns Type Value(s) Note(s)
column Integer*
0 to screenWidth -1
On the C128, this is relative to the active WINDOW
* All BASIC functions return a floating-point type, but the value is derived (converted) from the type shown. 
 
  Purpose  
Return horizontal position of the text cursor.
 
  Remarks  
The POS function reports the current horizonatal position (column) of the text cursor.  The text cursor is normally not shown while a program is running; it is the screen location where the next PRINT will occur.  The returned column is a zero-based value.  In other words, the left-most character position is zero, the position to the right of that is 1, and so on until the maximum of screenWidth -1 where screenWidth is 22 for VIC-20, and 40 or 80 for other CBMs.
 
Because the C128 has two video displays, the screenWidth is physically either 40 or 80 depending on which is currently active (see GRAPHIC).  On the C128, the column is relative to the active WINDOW.  So if the the text cursor is at the left-most position of the current window (which may not physically be the left-most position on the screen) the reported column will be zero.  Note the TED series (C16 and Plus/4) allow windows to be created with ESC sequences, but the returned POS is always relative to the physical screen.
 
The POS function can be considered to be the complement to CHAR or TAB.  Unfortunately, CBM BASIC does not provide a function to determine the row of the text cursor.
 
If dummy is not numeric, a TYPE MISMATCH ERROR is generated.  If dummy is omitted or not a valid expression, a SYNTAX ERROR occurs.
 
Examples:
PRINT POS(0)
 0
 
READY.
PRINT "HELLO";: X=POS(0)
HELLO
READY.
PRINT X
 5

READY.
 
  Compare With  
 
  Contrast With  
 
  See Also  

© H2Obsession, 2014
Comments