package DYN is -- a collection of several dynamic string functions. ------------------------------------------------------------------------------ -- This is a package of several string manipulation functions based on -- -- a built-in dynamic string type DYN_STRING. It is an adaptation and -- -- extension of the package proposed by Sylvan Rubin of Ford Aerospace and -- -- Communications Corporation in the Nov/Dec 1984 issue of the Journal of -- -- Pascal, Ada and Modula-2. Some new functions have been added, and much -- -- of the body code has been rewritten. -- ------------------------------------------------------------------------------ -- R.G. Cleaveland 07 December 1984: -- -- Implementation initially with the Telesoft Ada version 1.3. -- -- This required definition of the DYN_STRING type without use of a -- -- discriminant; an arbitrary maximum string length was chosen. This -- -- should be changed when an improved compiler is available. -- ------------------------------------------------------------------------------ type DYN_STRING is private; STRING_TOO_SHORT: exception; function D_STRING(CHAR: character) return DYN_STRING; -- Creates a one-byte dynamic string of contents CHAR. function D_STRING(STR : string ) return DYN_STRING; -- Creates a dynamic string of contents STR. function D_STRING(N: integer; B: natural := 0; F: character:= ' ') return DYN_STRING; function D_STRING(N: long_integer; B: natural := 0; F: character:= ' ') return DYN_STRING; -- for the two preceding functions, -- B is the number of bytes desired in the returned string. The -- first byte is reserved for the sign; it will be blank -- or '-'. If B is 0 or unspecified the length of the -- string returned is just enough for the sign and the -- significant digits. If the number would overflow B, -- the exception STRING_TOO_SHORT is raised. -- F is a leading-fill character. If B is not zero, bytes from 2 -- up to the first significant byte will be F. function D_STRING(FLT : float; AFT : integer) return DYN_STRING; -- Creates a dynamic string representationof the number FLT -- in fixed point notation with AFT decimal places. -- The following four functions convert from dynamic strings to the -- desired representation: function CHAR(DSTR: DYN_STRING) return character; function STR (DSTR: DYN_STRING) return string; function INT (DSTR: DYN_STRING) return integer; function FLT (DSTR: DYN_STRING) return float; -- (No function LI as yet) function LENGTH(DSTR: DYN_STRING) return natural; function "<" (DS1, DS2: DYN_STRING) return boolean; function "&" (DS1, DS2: DYN_STRING) return DYN_STRING; function SUBSTRING (DSTR: DYN_STRING; -- Returns a subpart of this string START : natural; -- starting at this position LENGTH : natural) -- and of this length. return DYN_STRING; function RIGHT (DSTR: DYN_STRING; -- Returns the part of this string START : natural) -- starting here and to the end. return DYN_STRING; function INDEX (SOURCE_STRING, --If this string contains PATTERN_STRING: DYN_STRING; --this string starting at or AFTER START_POS: integer) --this position, the position of return integer; --such start is returned. -- If the string lengths prohibit the search -1 is returned. -- If no match was found, 0 is returned. -- (This is like the INSTR function of BASIC). function RINDEX (SOURCE_STRING, --If this string contains PATTERN_STRING: DYN_STRING; --this string starting at or BEFORE START_POS: integer) --this position, the position of return integer; --such start is returned. -- If the string lengths prohibit the search -1 is returned. -- If no match was found, 0 is returned. function UPPERCASE (DSTR: DYN_STRING) return DYN_STRING; -- Returns with all lower-case characters changed to -- uppercase. private -- The following definition is used for the early release Telesoft -- compiler: type DYN_STRING is -- Interim definition record -- for use with SIZE: natural := 0; -- Telesoft subset. DATA: string(1..100); -- end record; -- -- Use this definition for use with validated compiler: -- type DYN_STRING (SIZE : natural := 0) is -- record -- DATA: string(1..SIZE); -- end record; Package TITLE_PAGE is new TITLE_PAGE_PACKAGE (Developing_organization => "WIS JPMO", Author => "Richard G. Cleaveland", Contact => "Richard G. Cleaveland", Address => ("WIS JPMO", , "Washington","DC", "203306600"), Phone => (703,285,5071) Date_Submitted => (16, Jan, 1985)); Package Technical_Parameters is new Technical_Parameters_Package (Lines_of_Source_Code => TBD, Development_Compiler => (WICAT, TELESOFT ROS), --Planned_compilers_supported => (( , ) ( , )), --Auxilliary_files_size => ( )); Package DEVELOPMENT_SCHEDULE_AND_STATUS is new SCHEDULE_PACKAGE (Completed_events => ((first_build, (07, Dec, 1984))), (Delivery, (18, Mar, 1985))); --(Scheduled_events => ( ( , ( , , )), end DYN;