Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Problemt mit einer if-Abfrage (https://www.delphipraxis.net/51562-problemt-mit-einer-if-abfrage.html)

Clane 15. Aug 2005 07:58


Problemt mit einer if-Abfrage
 
also ich habe folgendes programmiert

Delphi-Quellcode:
if not command = 'shutdown' and not command = 'lockwst' then showmessage(msg)
der sinn:: wenn command nich = shutdown ist und gleichzeitig aber auch nich = lockwst ist soll eine shwomessage angezeigt werden

mein compiler mäckert aber und zwar das hier

Zitat:

[Error] Unit1.pas(46): E2015 Operator not applicable to this operand type
[Error] Unit1.pas(46): E2015 Operator not applicable to this operand type
[Warning] Unit1.pas(46): W1023 Comparing signed and unsigned types - widened both operands
[Error] Unit1.pas(46): E2010 Incompatible types: 'string' and 'Boolean'
[Fatal Error] Server.dpr(5): F2063 Could not compile used unit 'Unit1.pas'

turboPASCAL 15. Aug 2005 08:04

Re: Problemt mit einer if-Abfrage
 
Delphi-Quellcode:
if not (command = 'shutdown') and not (command = 'lockwst') then
Klammern nicht vergessen !

Sharky 15. Aug 2005 08:15

Re: Problemt mit einer if-Abfrage
 
Hai PBiggi,

wenn ich dich richtig verstehe soll die Meldung kommen wenn command nicht "shutdown" oder "lockwst" ist?

dann könntest Du das auch so mache:
Delphi-Quellcode:
 if not ((command = 'shutdown') or (command = 'lockwst')) then
Ist so einfach finde ich.

Clane 15. Aug 2005 08:17

Re: Problemt mit einer if-Abfrage
 
genau und danke so funktionierts ;)

RavenIV 15. Aug 2005 08:54

Re: Problemt mit einer if-Abfrage
 
Zitat:

Zitat von Sharky
dann könntest Du das auch so mache:
Delphi-Quellcode:
 if not ((command = 'shutdown') or (command = 'lockwst')) then

ist doch das gleiche wie
Delphi-Quellcode:
if (command <> 'shutdown') and (command <> 'lockwst') then
aber viel leichte zu durchschauen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz