Replacing readstring

Trying to run Fortran-Julia conversion script · GitHub with Julia 1.6.1 fails because of the lines

filename = string(ARGS[1])
code = readstring(filename)

Julia says

ERROR: LoadError: UndefVarError: readstring not defined
Stacktrace:
 [1] top-level scope
   @ c:\julia\fortran-julia.jl:104
in expression starting at c:\julia\fortran-julia.jl:104

I know readstring has been removed and that I should call read, but I don’t know what the alternative code should be.

code = read(filename, String)

(Note also that ARGS[1] is already a string; no need to call string.)

2 Likes

You can also in most cases use readchomp. That this is easier to do than just reading the string is a travesty, imo.

1 Like