Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi syntax prob (https://www.delphipraxis.net/24869-syntax-prob.html)

G G 27. Jun 2004 21:35


syntax prob
 
inkompatible typen sagt er, ich hab markiert wo der cursor stehen bleibt

image_num := strtoint (image_name2);
Delphi-Quellcode:
if image_num <> 1 and image_num <> 16 and image_num <>//hier bleibt cursor stehen
 31 and image_num <> 46 and image_num <> 61 and image_num <> 76 and image_num <> 91 and image_num <> 106 and image_num <> 121 and image_num <> 136 and image_num <> 151 and image_num <> 166 and image_num <> 181 and image_num <> 196 and image_num <> 211 and image_num <> 226 and image_num <> 241
then begin

Sharky 27. Jun 2004 21:37

Re: syntax prob
 
AND hat eine höhere Bindung. Darum klammern setzten.

Delphi-Quellcode:
if (image_num <> 1) and (image_num <> 16) and (image_num <> 31).....

Nikolas 27. Jun 2004 21:38

Re: syntax prob
 
Klammer??? Oder
if not in [6,21,61...]

Edit: Tjy, da war der Hai schneller. :(

G G 27. Jun 2004 21:40

Re: syntax prob
 
kannst du vielleicht etwas genauer zeigen wie man "if not in" benutzt? hab immer gedacht man müste immer alles ausschreiebn bei if sachen

Sharky 27. Jun 2004 21:44

Re: syntax prob
 
Zitat:

Zitat von G G
kannst du vielleicht etwas genauer zeigen wie man "if not in" benutzt? hab immer gedacht man müste immer alles ausschreiebn bei if sachen

Hai G G,

in diesem Fall ist es eine "Mengenoperation" und darum geht es.

Delphi-Quellcode:
begin
  if not (image_num IN 6,21,61...]) then
  begin
  end;
end;
[Edit]Erster :P :bounce1: :bounce2: :bounce1:
[Edit2] Aber himitsu hat ja auch alle zahlen getippt ;-)

Nikolas 27. Jun 2004 21:46

Re: syntax prob
 
nein, man kann auch eine Menge benutzen. Sieht dann so aus:
Delphi-Quellcode:
if not (a in [1,2,3]) then dosomething;
TOX

Edit: Also langsam find ich das echt nicht mehr lustig :evil:

himitsu 27. Jun 2004 21:47

Re: syntax prob
 
Delphi-Quellcode:
if not (image_num in [1, 16, 31, 46, 61, 76, 91, 106, 121, 136, 151, 166, 181, 196, 211, 226, 241]
then begin

[edit] och menno, zu langsam -.-


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:28 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