home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / misc / dstr3.abs < prev    next >
Encoding:
Text File  |  1988-05-03  |  6.1 KB  |  129 lines

  1. package DYN is -- a collection of several dynamic string functions.
  2.  
  3. ------------------------------------------------------------------------------
  4. --  This is a package of several string manipulation functions based on     --
  5. -- a built-in dynamic string type DYN_STRING.  It is an adaptation and      --
  6. -- extension of the package proposed by Sylvan Rubin of Ford Aerospace and  --
  7. -- Communications Corporation in the Nov/Dec 1984 issue of the Journal of   --
  8. -- Pascal, Ada and Modula-2.  Some new functions have been added, and much  --
  9. -- of the body code has been rewritten.                                     --
  10. ------------------------------------------------------------------------------
  11. -- R.G. Cleaveland 07 December 1984:                                        --
  12. --  Implementation initially with the Telesoft Ada version 1.3.             --
  13. -- This required definition of the DYN_STRING type without use of a         --
  14. -- discriminant; an arbitrary maximum string length was chosen.  This       --
  15. -- should be changed when an improved compiler is available.                --
  16. ------------------------------------------------------------------------------
  17.  
  18. type DYN_STRING is private;
  19. STRING_TOO_SHORT: exception;
  20.  
  21. function D_STRING(CHAR: character)  return DYN_STRING;
  22.         -- Creates a one-byte dynamic string of contents CHAR.
  23.  
  24. function D_STRING(STR : string   )  return DYN_STRING;
  25.         -- Creates a dynamic string of contents STR.
  26.  
  27. function D_STRING(N: integer;
  28.                   B: natural  := 0;
  29.                   F: character:= ' ') return DYN_STRING;
  30.  
  31. function D_STRING(N: long_integer;
  32.                   B: natural  := 0;
  33.                   F: character:= ' ') return DYN_STRING;
  34.  
  35.     -- for the two preceding functions,
  36.         -- B is the number of bytes desired in the returned string. The
  37.         --      first byte is reserved for the sign; it will be blank
  38.         --      or '-'.  If B is 0 or unspecified the length of the
  39.         --      string returned is just enough for the sign and the
  40.         --      significant digits.  If the number would overflow B,
  41.         --      the exception STRING_TOO_SHORT is raised.
  42.         
  43.         -- F is a leading-fill character.  If B is not zero, bytes from 2
  44.         --      up to the first significant byte will be F.
  45.     
  46.  
  47. function D_STRING(FLT : float; AFT : integer)  return DYN_STRING;
  48.         -- Creates a dynamic string representationof the number FLT
  49.         -- in fixed point notation with AFT decimal places.
  50.  
  51. -- The following four functions convert from dynamic strings to the
  52. -- desired representation:
  53. function CHAR(DSTR: DYN_STRING) return character;
  54. function STR (DSTR: DYN_STRING) return string;
  55. function INT (DSTR: DYN_STRING) return integer;
  56. function FLT (DSTR: DYN_STRING) return float;
  57. -- (No function LI as yet)
  58.  
  59. function LENGTH(DSTR: DYN_STRING) return natural;
  60. function "<" (DS1, DS2: DYN_STRING) return boolean;
  61. function "&" (DS1, DS2: DYN_STRING) return DYN_STRING;
  62.  
  63. function SUBSTRING (DSTR: DYN_STRING;      -- Returns a subpart of this string
  64.                     START  : natural;      -- starting at this position
  65.                     LENGTH : natural)      -- and of this length.
  66.                 return DYN_STRING;
  67.  
  68. function RIGHT (DSTR: DYN_STRING;          -- Returns the part of this string
  69.                 START  : natural)          -- starting here and to the end.
  70.                 return DYN_STRING;
  71.  
  72. function INDEX (SOURCE_STRING,              --If this string contains
  73.                 PATTERN_STRING: DYN_STRING; --this string starting at or AFTER
  74.                 START_POS: integer)         --this position, the position of
  75.                 return integer;             --such start is returned.
  76.                 -- If the string lengths prohibit the search -1 is returned.
  77.                 -- If no match was found, 0 is returned.
  78.                 -- (This is like the INSTR function of BASIC).
  79.  
  80. function RINDEX (SOURCE_STRING,             --If this string contains
  81.                 PATTERN_STRING: DYN_STRING; --this string starting at or BEFORE
  82.                 START_POS: integer)         --this position, the position of
  83.                 return integer;             --such start is returned.
  84.                 -- If the string lengths prohibit the search -1 is returned.
  85.                 -- If no match was found, 0 is returned.
  86.  
  87. function UPPERCASE (DSTR: DYN_STRING) return DYN_STRING;
  88.                 -- Returns with all lower-case characters changed to
  89.                 -- uppercase.
  90. private
  91.      
  92.      -- The following definition is used for the early release Telesoft
  93.      -- compiler:
  94.         type DYN_STRING is                      -- Interim definition
  95.            record                               -- for use with
  96.                SIZE: natural := 0;              -- Telesoft subset.
  97.                DATA: string(1..100);            --
  98.            end record;                          --
  99.      
  100.      -- Use this definition for use with validated compiler:
  101.      -- type DYN_STRING (SIZE : natural := 0) is
  102.      --    record
  103.      --        DATA: string(1..SIZE);
  104.      --    end record;
  105.            
  106.  
  107. Package TITLE_PAGE is new TITLE_PAGE_PACKAGE
  108.     (Developing_organization    => "WIS JPMO",
  109.      Author                     => "Richard G. Cleaveland",
  110.      Contact                    => "Richard G. Cleaveland",
  111.      Address                    => ("WIS JPMO",       ,
  112.                                     "Washington","DC", "203306600"),
  113.      Phone                      => (703,285,5071)
  114.      Date_Submitted             => (16, Jan, 1985));
  115.  
  116. Package Technical_Parameters is new  Technical_Parameters_Package
  117.    (Lines_of_Source_Code        => TBD,
  118.     Development_Compiler        => (WICAT, TELESOFT ROS),
  119.   --Planned_compilers_supported => ((      ,       )
  120.                                     (      ,       )),
  121.   --Auxilliary_files_size       => (   ));
  122.  
  123. Package  DEVELOPMENT_SCHEDULE_AND_STATUS is new SCHEDULE_PACKAGE
  124.    (Completed_events            => ((first_build, (07, Dec, 1984))),
  125.                                    (Delivery, (18, Mar, 1985)));
  126.  --(Scheduled_events            => ( (   , (  ,    ,     )),
  127.  
  128. end DYN;
  129.