home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / string1.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.0 KB  |  45 lines

  1.                                        -- Chapter 11 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure String1 is
  6.  
  7.    Line     : STRING(1..33);
  8.    NAME     : constant STRING := ('J','o','h','n');
  9.    JOB      : constant STRING := "Computer Programmer";
  10.    Address  : STRING(1..13) := "Anywhere, USA";
  11.    Letter   : CHARACTER;
  12.    EXAMPLE1 : constant STRING := "A";     -- A string of length 1
  13.    EXAMPLE2 : constant STRING := "";      -- An empty string
  14.  
  15. begin
  16.  
  17.    Line := "This is a test of STRINGS in Ada.";
  18.    Put(Line);
  19.    New_Line;
  20.    Put(NAME);
  21.    Put(" is a ");
  22.    Put(JOB);
  23.    Put(" and lives in ");
  24.    Put(Address);
  25.    New_Line(2);
  26.  
  27.    Address(3) := 'X';               -- Individual letters
  28.    Address(4) := 'Y';               -- Individual letters
  29.    Address(10..13) := NAME(1..4);   -- A slice
  30.    Put(Address);
  31.    New_Line;
  32.  
  33. end String1;
  34.  
  35.  
  36.  
  37.  
  38. -- Result of execution
  39.  
  40. -- This is a test of STRINGS in Ada.
  41. -- John is a Computer Programmer and lives in Anywhere, USA
  42. --
  43. -- AnXYhere,John
  44.  
  45.