[fpc-pascal]I don't understand value typecast

Stefan Becker becker at lufa-sp.vdlufa.de
Mon Jul 1 00:51:17 CEST 2002


Hi,
for a fast answer without compiling your example myself
I would say that you didn't have "Range Checking" ON.

Maybe that way your example might compile but not run.

I don't know.

Anyway.  You use "Type" casting to teach the compiler
about (new) memory structures (you want to use) and
how to use them.

example:

type
 BtrvDate =3D LongInt;
 BtrvTime =3D LongInt;
 String4 =3D String[4];
 FixRec =3D packed record
  null   : byte;           {1}
  buch   : char;           {2}
  EingDt : BtrvDate;       {3,4,5,6}
  Jnr    : word;           {7,8    the Nr SampleNr. according to book}
  grp    : word;           {9,10}
  code   : word;           {11,12   Anzahl / ParameterNr.}
  Ab_date: BtrvDate;       {13,14,15,16  Abschlu=DF_datum}
  An_date: BtrvDate;       {17,18,19,20}
  An_time: BtrvTime;       {21,22,23,24}
  Typtail: shortint;       {25  the kind of tail}
  Up_date: BtrvDate;       {26,27,28,29  update-date}
  Up_time: BtrvTime;       {30,31,32,33  update-time}
  uOwner : dword;          {34,35,36,37  4 byte}
  gOwner : dword;          {38,39,40,41  4 byte}
  Stat   : string4;        {42,43,44,45,46}
  ApplId : word;           {47,48}
 end;


Best write what you are trying to do and then maybe try again!


my regards,
Stefan







-----Urspr=FCngliche Nachricht-----
Von: Luis Del Aguila <aguila3000 at terra.com.pe>
An: fpc-pascal at lists.freepascal.org <fpc-pascal at lists.freepascal.org>
Datum: Sonntag, 30. Juni 2002 22:31
Betreff: [fpc-pascal]I don't understand value typecast


>In the manual explain that the value typecast doesn't work, when the type
>size of the expression and the size of the type cast  not must be the same.
>(page 58. ref.pdf)
>But this program compile.
>
>Var a:integer;
>      b:char;
>      c:boolean;
>      d:word;
>Begin
>   a:=3Dinteger('A');
>   b:=3DChar(4875);
>   c:=3Dboolean(100);
>End.
>
>How work the value typecast?
>thanks.
>
>
>
>
>_______________________________________________
>fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freepascal.org/lists/fpc-pascal/attachments/20020630/293e=
96de/attachment.htm


More information about the fpc-pascal mailing list