Re: file_exists and file name in quotes

new topic     » goto parent     » topic index » view thread      » older message » newer message
clk824 said...

I get value of environment variable which contains full path of executable file in quotes. In my case value is: "C:\Program Files\Notepad++\notepad++.exe"

Well, it seems like you have defined the EDITOR symbol to have quotes around the file name. If this is how you want it to stay then you will need to strip off the quotes.

function dequote_env(sequence name) 
    object res 
    res = getenv(name) 
    if sequence(res) then 
        if length(res) >= 2 then 
            if res[1] = '"' and res[$] = '"' then 
                res = res[2..$-1] 
            end if 
        end if 
    end if 
 
    return res 
end function 
sequence editor = dequote_env("EDITOR") 
 
if not file_exists(editor) then 
	editor = dequote_env("WINDIR") & "\\notepad.exe" 
end if 
 
system_exec(sprintf(`"%s"`, {editor}) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu