[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

using "NOT" in File.exists?

Peter Bailey

7/19/2007 12:35:00 PM

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.

--
Posted via http://www.ruby-....

4 Answers

Alex Young

7/19/2007 12:40:00 PM

0

Peter Bailey wrote:
> 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.
>
Try:

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

--
Alex

Arie Kusuma Atmaja

7/19/2007 12:45:00 PM

0

On 7/19/07, Peter Bailey <pbailey@bna.com> wrote:
> 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.

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>

--
Arie || ariekeren, http://ariekusumaatmaja.wor...
http://groups.yahoo.com/grou...
"Never say RTFM. Turn the trolls into committers", Audrey Tang -
conisli-ofun.pdf

Peter Bailey

7/19/2007 12:46:00 PM

0

Alex Young wrote:
> Peter Bailey 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 !

--
Posted via http://www.ruby-....

Arie Kusuma Atmaja

7/20/2007 2:59:00 AM

0

On 7/19/07, Peter Bailey <pbailey@bna.com> 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>

--
Arie || ariekeren, http://ariekusumaatmaja.wor...
http://groups.yahoo.com/grou...
"Never say RTFM. Turn the trolls into committers", Audrey Tang -
conisli-ofun.pdf