[Gambas-user] Doesn't IF NOT exist? Bug or feature? Or my bad logic?

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Sep 17 17:58:41 CEST 2009


Benoît Minisini schrieb:
>> Rolf-Werner Eilert wrote:
>>> Just stumbled over this when trying to implement a small copying
>>> function:
>>>
>>>    FOR EACH datei IN Dir(opfad, odatei & ".*")
>>>      IF NOT file.Ext(opfad &/ datei) = "lock" THEN
>>>        COPY opfad &/ datei TO ziel &/ datei
>>>        SELECT CASE file.Ext(ziel &/ datei)
>>>        CASE "fehl", "feldbak", "felder", "notizen"
>>>          SHELL "chgrp kartei " & ziel &/ datei WAIT
>>>          SHELL "chmod 660 " & ziel &/ datei WAIT
>>>        CASE "konto", "kontobak", "ktx", "ktxbak"
>>>          SHELL "chgrp konto " & ziel &/ datei WAIT
>>>          SHELL "chmod 660 " & ziel &/ datei WAIT
>>>        END SELECT
>>>      END IF
>>>    NEXT
>>>
>>> IF NOT ... = ... THEN
>>>
>>> wouldn't copy anything, although only one file has the given extension.
>>> When I change this line into
>>>
>>> IF file.Ext(opfad &/ datei) <> "lock" THEN
>>>
>>> everything runs as expected. Doesn't make sense to me as both ways
>>> should mean the same in my understanding of logical NOT (which doesn't
>>> mean too much... :-) )
>>>
>>> Regards
>>>
>>> Rolf
>>  From the docs, NOT is an operator that makes a boolean it's opposite
>> (TRUE turns to FALSE and vice versa) and will also invert each bit in an
>> integer.  NOT(11) = -12 because that's what you get when you change
>> every bit from on to off and vice versa.
>>
>>  From other examples in the docs, if you NOT a string with something in
>> it, you will get FALSE.  However, if you NOT an empty string, you will
>> get TRUE.
>>
> 
> In other words, try to use brackets: IF NOT (...) = ... THEN
> 
> 

Aaah - ok, now it's clear to me, too ;-)

Regards

Rolf





More information about the User mailing list