Next / Previous / Contents / TCC Help System / NM Tech homepage

29. Scan.tab(): Move to a specific position

logscan.py
# - - -   S c a n . t a b

    def tab ( self, p ):
        '''Move to position p in the current line.
        '''
        #-- 1 --
        # [ newPos  :=  effective-pos(p) ]
        newPos = self.__effPos ( p )

The rest of the logic is similar to Section 28, “Scan.move(): Advance the scan position”, as if we were moving the position by an amount newPos-self.pos).

logscan.py
        #-- 2 --
        # [ if newPos is within the current line ->
        #     self  :=  self positioned at newPos in the current line
        #     return text between self's current position and newPos
        #   else -> raise IndexError ]
        return self.move ( newPos - self.pos )