Board index » delphi » IS operator problems in Delphi3

IS operator problems in Delphi3

Hello,

First up, this is my first go at Delphi!  Also I did not originally write
this code, it is some Delphi 1 code that I need to get going in Delphi3or5
so I can correct a few Year 2000 issues

I've got a problem with the IS operator in Delphi 3, below is the procedure
where the problem in comilation is occuring ...

The error coming up is : "Operator not applicable to this operand type"

Code follows :-  (run a search for *MARK* and that'll be near it)

PROCEDURE TAVScript.WriteImage(const X,Y,Width,Height,FrameWidth : Single;
          const Align : TAVDTextAlign;
          const Image : TGraphic);
VAR ObjectData : TAVDImageRec;
    Len1,Len2 : Word;
    AStream: TAVStream;
    HeaderPos : LongInt;

BEGIN
    OpenReport;
    IF FOpenReport THEN
    BEGIN
 WITH ObjectData DO
 BEGIN
     Len1 := SizeOf(ObjectData);
     Header.OLength := Len1;
     Header.OType   := Word(avImage);
     Data.PosX  := X;
     Data.PosY  := Y;
     Data.IWidth := Width;
     Data.IHeight:= Height;
     Data.IFrame := FrameWidth;
     Data.IAlign := Ord(Align);

{-***************************************************** }

            { *MARK* Something not right here ....     }

     IF Image IS TIcon THEN
  Data.IType := Ord(itIcon)
     ELSE IF Image IS TBitMap THEN           { <---- Error is here! maybe }
  Data.IType := Ord(itBitMap)
     ELSE IF Image IS TMetaFile THEN
  Data.IType := Ord(itMetafile)
     ELSE Data.IType := Ord(itUnknown);

{******************************************************** }

     Data.DataLen := 0;
     { Write the header to the file }
     HeaderPos := FileSize(FCurrentReport);
     Seek(FCurrentReport,HeaderPos);
     BlockWrite(FCurrentReport,ObjectData,Len1,Len2);
     {
     IF Len1 <> Len2 THEN...
     }
     { Now write the image data to the file }
     AStream := TAVStream.Create(FCurrentReport);
     TRY
  WITH AStream DO
  BEGIN
      Image.SaveToStream(AStream);
      Data.DataLen := StreamSize;  { Get size of saved data }
  END;
     FINALLY
  AStream.Free;
     END;
     { Having written the stream data we now need to go back and
       rewrite the header to include the length of the data block }
     IF Data.DataLen > 0 THEN
     BEGIN
  Seek(FCurrentReport,HeaderPos);
  BlockWrite(FCurrentReport,ObjectData,Len1,Len2);
  {
  IF Len1 <> Len2 THEN...
  }
                { Now return to end of file }
  Seek(FCurrentReport,FileSize(FCurrentReport));
     END;
 END;
    END;
END;

Your help would be greatly appreciated!  (apologies if you get this message
twice, my first sending didn't go through :-(

Mark
m...@storagedirect.REMOVETHISBIT.com

 

Re:IS operator problems in Delphi3


In article <qLvZ4.1053$Ym5.15...@news2-win.server.ntlworld.com>,
  "Mark Smith" <m...@storagedirect.REMOVETHISBIT.com> wrote:
[...]
Quote
> The error coming up is : "Operator not applicable to this operand
type"

[...]
>      IF Image IS TIcon THEN
>   Data.IType := Ord(itIcon)
>      ELSE IF Image IS TBitMap THEN           { <---- Error is here!
maybe }
>   Data.IType := Ord(itBitMap)

[...]

    I bet the problem is that there's two TBitmap's
in Delphi (speaking of bad design). Here you want
Graphics.TBitmap and depending on the order of units
in the "uses" clauses you may be getting Windows.TBitmap
instead. Try

ELSE IF Image IS Graphics.TBitMap THEN

Sent via Deja.com http://www.deja.com/
Before you buy.

Re:IS operator problems in Delphi3


Ahhh, my hero!

Thanks for that.

Only a few hundred more compile errors to go ... ho hum!

Mark

Other Threads