

WriteFileLine: "myFile.txt", "The present year is ", 2000 + 13, "."Īnd likewise you use writeFile if you don't want a newline symbol at the end of the file. You write into a new text file just as you write into the Info window: To guard against this situation, we could check the existence of the file, and supply a default value in case the file does not exist: However, this script will fail if the file height.inf does not exist. Suppose that the file height.inf may contain an appropriate value for a numeric variable called height, which we need to use in our script. If the file does not exist, the script terminates with an error message.

To read the contents of an existing text file into a string variable or into a numeric variable, you use
#HOW TO OPEN A NEW TXT FILE ON MAC FULL#
You can also use full path names such as "C:/Users/Paolo/project1/hello.wav" on Windows and "/Users/Paolo/project1/hello.wav" on the Mac. Note that fileName$ is taken relatively to the folder where the script is saved for instance, if your script is in the folder Paolo/project1, then the file name "hello.wav" refers to Paolo/project1/hello.wav, the file name "yesterday/hello.wav" refers to Paolo/project1/yesterday/hello.wav, and the file name "./project2/hello.wav" refers to Paolo/project2/hello.wav ("." goes one folder up). Which returns 1 (true) if the file exists and can be read, and 0 (false) otherwise. You can check the availability of a file for reading with the function fileReadable ( fileName$) You can read from and write to text files from a Praat script.
