Jürgen Krämer wrote:
Hi,
SHANKAR R-R66203 wrote:
I am trying to use the filereadable function.
My code looks like given below (This code is part of a function) -
if (!filereadable("a:dataFile")
^ ^
remove the quotes.
let @/ = rs_searchString
keepjumps exec rs_ori_lineNum
echohl Todo
echomsg a:dataFile " Cannot open file for reading"
echohl NONE
return
endif
a:dataFile is the argument passed to the function, while calling the
function.
This does not seem to work.
Eventhough the file is present, the function reports, the file is not
present.
Regards,
Jürgen
Also, if your function wants to refer to variables defined outside the
function, the variable's name should be prefixed by g: (for a global
variable) or s: (for a script-local variable), otherwise a
function-local variable will be assumed -- and you will get "Error:
Undefined variable rs_searchString" and/or "Error: Invalid expression".
Outside of any function, a variable name with no prefix refers to a
global variable.
Best regards,
Tony.