Search code examples
file-writingpari-gp

writing an output to a file in Gp Pari


I'm running a rather long computation on Gp Pari, and Pari crashed in the middle of the computation, effectively wasting a week of computation time. Before I run the program again, I would like to figure out a way write the outputs to a file as they are being computed so that if this happens again, I'll be able to start where the program left off instead of needing to start over.

With that said, I cannot for the life of me get Pari's read function to work properly. Every variation of the code

for(i=1,10, write("C:\Users\Jonathan Hales\Desktop\pari_data.txt",i))

just gives me the error

"write: error opening output file: `UsersJonathan HalesDesktoppari_data.txt'."

I can however use the metacommand

\w"C:\Users\Jonathan Hales\Desktop\pari_data.txt" and that will print the last output from pari to the document. I can't however use a metacommand in the middle of a for loop, defeating the purpose of writing it to a document in the first place.


Solution

  • Use a forward slash (/) rather than a back slash (\) to separate parts of the path. Backslash is the escape character, so you can also double it up.