Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
      (divide)
      (equal)
      (less)
      (minus)
      (more)
      (multiply)
      (plus)
      (power)
      Abs
      And
      Append
      Asc
      Atn
      Auto
      Backup
      Bank
      Begin
      Bend
      Bload
      Boot
      Box
      Bsave
      Bump
      Catalog
      Char
      Chr
      Circle
      Close
      Clr
      Cmd
      Collect
      Collision
      Color
      Concat
      Cont
      Copy
      Cos
      Data
      Dclear
      Dclose
      Dec
      Def
      Delete
      Dim
      Directory
      Dispose
      Dload
      Do
      Dopen
      Draw
      Ds
      Ds string
      Dsave
      Dverify
      El
      Else
      End
      Envelope
      Er
      Err
      Exit
      Exp
      Fast
      Fetch
      Filter
      Fn
      For
      Fre
      Get
      Get num
      Getkey
      Go
      Gosub
      Goto
      Graphic
      Gshape
      Header
      Help
      Hex
      If
      Input
      Input num
      Instr
      Int
      Joy
      Key
      Left
      Len
      Let
      List
      Load
      Locate
      Log
      Loop
      Mid
      Monitor
      Movspr
      New
      Next
      Not
      Off
      On
      Open
      Or
      Paint
      Peek
      Pen
      Pi
      Play
      Pointer
      Poke
      Pos
      Pot
      Print
      Print num
      Pudef
      Quit
      Rclr
      Rdot
      Read
      Record
      Rem
      Rename
      Renumber
      Restore
      Resume
      Return
      Rgr
      Right
      Rlum
      Rnd
      Rreg
      Rspcolor
      Rsppos
      Rsprite
      Run
      Rwindow
      Save
      Scale
      Scnclr
      Scratch
      Sgn
      Sin
      Sleep
      Slow
      Sound
      Spc
      Sprcolor
      Sprdef
      Sprite
      Sprsav
      Sqr
      Sshape
      St
      Stash
      Step
      Stop
      Str
      Swap
      Sys
      Tab
      Tan
      Tempo
      Then
      Ti
      Ti string
      To
      Trap
      Troff
      Tron
      Until
      Using
      Usr
      Val
      Verify
      Vol
      Wait
      While
      Width
      Window
      Xor
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
KeywordAbbreviationToken (hex)Version(s)Classification
POSnoneB91.0+Function

 Syntax 
POS dummy )
 
ParametersTypeLegal Value(s)Note(s)
dummyNumeric
any
 
ReturnsTypeValue(s)Note(s)
columnInteger*
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