🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #32545

Re: Using constants & in

#32545
From: Brendan Bosman
Date: Fri, 22 Nov 2002 12:10
96 lines
2457 bytes
Hi

>   if (qryStatus.FieldByName('oldstatus').AsInteger in
[STATUS_NEW..STATUS_CANCELLED]) then


Are you sure that qryStatus.FieldByName('oldstatus').AsInteger return a
value between 10 and 1000, where 10 and 1000 in included?

I can not see any thing wrong with it?


Something else:

(1)
var
  a: DWORD;
begin
  a := 9;
  if a in [9,20] then
  begin
    beep
  end;
end;


this code will beep, but


(2)

 if 9 in [9,20] then
  begin
    beep
  end;


will not beep?

I know the statement (2) is by default true, so it should make the beep, but
it does not?


if you say
(3)

 if not (9 in [9,20]) then
  begin
    beep
  end;


the compiler ignores the while block of code?


Any ideas?
Regards
Brendan Bosman




















"Stephen Froude" <sfroude@teleplan-uk.c0m> wrote in message
news:3dde1a3b$1@newsgroups.borland.com...
>
> Can anyone tell me why this if statement always return False?
>
>   if (qryStatus.FieldByName('oldstatus').AsInteger in
[STATUS_NEW..STATUS_CANCELLED]) then
>
> where STATUS_NEW & STATUS_CANCELLED are constants declared as
>
> STATUS_NEW: Integer = 100;
> STATUS_CANCELLED: Integer = 1000;
>
> I've descovered that the AsInteger property returns a LongInt so tried
copyying the value into a local Integer variable but it still returns False.
>
> However if I substitute the constants for their values the if statement
returns True.
Technical Details
Message-ID: <3dde1f33@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail
References: <3dde1a3b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,1c6f6604b711dd81
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2002-11-22 04:15:45 PST
From: "Brendan Bosman" <brendan.bosman@syssol.ie>
Newsgroups: borland.public.delphi.language.objectpascal
References: <3dde1a3b$1@newsgroups.borland.com>
Subject: Re: Using constants & in
Date: Fri, 22 Nov 2002 12:10:44 -0000
Lines: 98
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 213.105.178.230
Message-ID: <3dde1f33@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1037967155 213.105.178.230 (22 Nov 2002 04:12:35 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail