3

I need to run a file in JULIA. To do so, I type the next command:

include("C:\Users\...\...\...\...\Function_Codes\File.jl")

The problem is that it does not recognise the backslashes, and I have to change them manually to put the same path with forwarding slashes:

include("C:/Users/.../.../.../.../Function_Codes/File.jl")

Can I configure JULIA to interpret the path correctly with backslashes? If not, how can I convert the path automatically instead of changing the slashes manually one-by-one

5
  • 1
    Use raw string literals, which don't expand escape sequences like \uxxxx Aug 15, 2021 at 15:09
  • does it mean just putting 'raw' before the path? So the route would be include(raw"C:\Users\...\...\...\...\Function_Codes\File.jl")
    – nekovolta
    Aug 15, 2021 at 15:18
  • 1
    Yes. You can also escape the backslashes instead, so include("C:\\Users\\...\\...\\...\\...\\Function_Codes\\File.jl").
    – pfitzseb
    Aug 15, 2021 at 15:22
  • 1
    I also think you can always use / because Julia will correctly handle it if you're on Windows?
    – jling
    Aug 15, 2021 at 16:12
  • 1
    What about joinpath(homedir(), "...", "Function_Codes", "File.jl")? Aug 16, 2021 at 0:59

1 Answer 1

5

I verified that putting 'raw' before the path works perfectly fine from the comments added to my question. The user @Brian suggested this solution.

The command would be:

include(raw"C:\Users\...\...\...\...\Function_Codes\File.jl")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.