pushBack                package:base                R Documentation

_P_u_s_h _T_e_x_t _B_a_c_k _o_n _t_o _a _C_o_n_n_e_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Functions to push back text lines onto a connection, and to
     enquire how many lines are currently pushed back.

_U_s_a_g_e:

     pushBack(data, connection, newLine = TRUE)
     pushBackLength(connection)

_A_r_g_u_m_e_n_t_s:

    data: a character vector.

connection: A connection.

 newLine: logical. If true, a newline is appended to each string pushed
          back.

_D_e_t_a_i_l_s:

     Several character strings can be pushed back on one or more
     occasions. The occasions form a stack, so the first line to be
     retrieved will be the first string from the last call to
     'pushBack'.  Lines which are pushed back are read prior to the
     normal input from the connection, by the normal text-reading
     functions such as 'readLines' and 'scan'.

     Pushback is only allowed for readable connections in text mode.

     Not all uses of connections respect pushbacks, in particular the
     input connection is still wired directly, so for example parsing
     commands from the console and 'scan("")' ignore pushbacks on
     'stdin'.

_V_a_l_u_e:

     'pushBack' returns nothing.

     'pushBackLength' returns number of lines currently pushed back.

_S_e_e _A_l_s_o:

     'connections', 'readLines'.

_E_x_a_m_p_l_e_s:

     zz <- textConnection(LETTERS)
     readLines(zz, 2)
     pushBack(c("aa", "bb"), zz)
     pushBackLength(zz)
     readLines(zz, 1)
     pushBackLength(zz)
     readLines(zz, 1)
     readLines(zz, 1)
     close(zz)

