Using "NOT" in File.exists?

Hello,
I want to create a boolean variable for a “not” statement. When I do a
“not File.exists?” in IRB, it works fine. But, it doesn’t work when it’s
part of a variable declaration. Can someone help me to create a truth
variable for a statement like this?

Thanks,
Peter

doesn’t work in script. . . .
pngthere = not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

in IRB. . . .
not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)
works fine.

Peter B. wrote:

pngthere = not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

in IRB. . . .
not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)
works fine.

Try:

pngthere = !File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

Alex Y. wrote:

Peter B. wrote:

pngthere = not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

in IRB. . . .
not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)
works fine.

Try:

pngthere = !File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

Ahhh, simple, of course. You’re a prince. Thanks !

On 7/19/07, Peter B. [email protected] wrote:

pngthere = not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

in IRB. . . .
not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)
works fine.

sayang:~/2 arie$ irb
Arigatou jyanai! Pizza wa (2) ni-mai, OK!
Terima kasih boleh2 saja, pizza+hotel_empuk itulah yg lebih dari boleh2
saja
irb(main):001:0> File.exists?(‘1.tcl’)
=> true
irb(main):002:0> !File.exists?(‘1.tcl’)
=> false
irb(main):003:0> “a” unless File.exists?(‘1.tcl’)
=> nil
irb(main):004:0> puts “a” unless File.exists?(‘1.tcl’)
=> nil
irb(main):005:0> puts “a” if File.exists?(‘1.tcl’)
a
=> nil
irb(main):006:0> tclthere = !File.exists?(‘1.tcl’)
=> false
irb(main):007:0> tclthere2 = not File.exists?(‘1.tcl’)
SyntaxError: compile error
(irb):7: syntax error, unexpected kNOT
tclthere2 = not File.exists?(‘1.tcl’)
^
from (irb):7
from :0
irb(main):008:0>

On 7/19/07, Peter B. [email protected] wrote:

doesn’t work in script. . . .
pngthere = not File.exists?(“L:/png/#{pngdir}/#{pngfile}”)

pngthere = (not File.exist?(‘pngfile’))

sayang:~/2 arie$ touch pngfile
sayang:~/2 arie$ irb
irb(main):001:0> pngthere = (not File.exist?(‘pngfile’))
=> false
irb(main):002:0>