Reading to and writing from files

Cards (7)

  • How do you open files?
    OPENREAD
  • what does the READLINE function do?
    used to return a line of text from the file
  • what is used to determine that the end of a file has been reached?
    ENDOFFILE()
  • What function do you use to open a fille and write, and create a new line of text?
    openWrite
    writeLine
  • myFile = OPENREAD(”sample.txt”)
    x = myFile.READLINE()
    myFile.CLOSE()
  • myFile = OPENREAD(“sample.txt”)
    WHILE NOT myFile.ENDOFWHILE()
    PRINT(myFile.READLINE())
    ENDWHILE
    myFile.CLOSE()
  • myFile = OPENWRITE(“sample.txt”)
    myFile.WRITELINE(“hello world“)
    myFile.CLOSE()