0

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.

JonHales
  • 125
  • 6

1 Answers1

1

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.

Andrew
  • 873
  • 4
  • 10
  • Thank you for your answer, it worked perfectly. Just out of curiosity, why did the backslash not make a difference when using the meta command \r or \w? – JonHales May 17 '19 at 18:34
  • 1
    My guess that is a inconsistency in PARI - it is probably not possible to introduce a \n (linefeed) or \t (tab) within meta command strings. Note that after \w it is not even necessary to have quotes so technically the file name after \w isn't a PARI string (it is being parsed by some other set of rules) – Andrew May 19 '19 at 01:57
  • Thank you for your explanation, that makes sense! – JonHales May 20 '19 at 02:23