[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 SIZEOF              Find Size of Variable or Structure               pp 144

 Syntax:  SizeOf (Name) ;

 Type:    Integer

 Form:    Function

 Purpose: Returns number of bytes in memory that are occupied by a variable
          or defined Type.

 Notes:   SizeOf allows the program code to know how large a variable is
          at runtime.  The Move and FillChar procedures don't respect the
          bounds of the variables they interact with.  Both can easily overlay
          their destinations if the counts are incorrect.  SizeOf gives
          an accurate means of determining the size of the destination.


 ----------------------------------------------------------------------------


 Usage:
        CONST
          Count : Integer = 50            ;  { Variable count          }
       VAR
          Var1  : String [50]             ;  { Source string           }
          Var2  : String [80]             ;  { Destination string      }

       BEGIN
          Move (Var1,Var2,Count)          ;  { This will move ok       }
          Move (Var2,Var1,80)             ;  { This will overflow Var1 }
          Move (Var1,Var2,SizeOf(Var1))   ;  { This will move safely   }
       END.

See Also: FillChar Move
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson