Replacing readstring

Trying to run https://gist.github.com/rafaqz/fede683a3e853f36c9b367471fde2f56 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.

1 Like

code = read(filename, String)

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

4 Likes

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

4 Likes

The Julia Manual still has references to readstring.

My preferred fix would actually be to just redefine readstring—I still miss it.

1 Like

Could you point out one example?