home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol019 / strlib.doc < prev    next >
Text File  |  1984-04-29  |  3KB  |  142 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.     (************************************************)
  7.     (*                        *)
  8.     (*        STRING LIBRARY            *)
  9.     (*                        *)
  10.     (************************************************)
  11.  
  12.  
  13.  
  14.  
  15. (*    Version 3.0  31 May 1980/Raymond E. Penley *)
  16.  
  17.     (************************************************)
  18.  
  19.  
  20.  
  21. FUNCTION INDEX(SOURCE,Pattern) : INTEGER ; EXTERNAL;
  22.     (*---this is a Pascal/Z extension---*)
  23.  
  24.     Returns the position of the first occurrence of the
  25. Pattern in SOURCE to be scanned. The integer value of the
  26. position of the first character in the matched pattern will
  27. be returned. If no match occurred then zero will be returned.
  28.  
  29.   If for example the string THIS contained:
  30.     'Today is the first day.'
  31.     PATTERN := 'is';
  32.     N := INDEX(THIS,pattern);
  33.     writeln(N);
  34.  
  35.     would write:    7
  36.  
  37.     (****************************************)
  38.     (*    UCSD PASCAL            *)
  39.     (*                    *)
  40.     (*     K := POS(Pattern,SOURCE);    *)
  41.     (*                    *)
  42.     (* NOTE that Pascal/Z is 180 degrees    *)
  43.     (* out of wack!                *)
  44.     (****************************************)
  45.  
  46.     (************************************************)
  47.  
  48.  
  49.  
  50. PROCEDURE PRINT(STRING);
  51.  
  52.   Prints to the console the string passed; does NOT issue a
  53.   carriage-return/line-feed. 
  54.  
  55.     PRINT(This);          {no CR/LF    }
  56.     PRINT(This);writeln;    {with CR/LF    }
  57.     PRINT(A[5]);write('    ');PRINT(Newstr);writeln;
  58.  
  59.     (************************************************)
  60.  
  61.  
  62.  
  63. PROCEDURE COPY(New_string,Source,POS,COUNT);
  64.  
  65.     COPY(<NEW> := <SOURCE>,<starting at>,<# of chars>);
  66.     COPY(Newstr,Title,1,9);
  67.  
  68.     Returns a string containing count <chars> starting at
  69.     <POS> position in SOURCE.
  70.  
  71.     (*****************************************)
  72.     (*    UCSD PASCAL             *)
  73.     (*                     *)
  74.     (* New_string := COPY(Source,POS,COUNT); *)
  75.     (*                     *)
  76.     (*****************************************)
  77.  
  78.     (************************************************)
  79.  
  80.  
  81.  
  82. PROCEDURE CONCAT(New_string,arg1_string,arg2_string);
  83.  
  84.     CONCAT(Newstr,ThisString, ThatString);
  85.  
  86.     This CONCAT works in the same fashion as CPM's PIP does.
  87.   That is:
  88.         CONCAT( New String := Arg1, Arg2 );
  89.  
  90.   There may be only two arguments. A string is returned which is
  91.   the concatenation of both strings passed provided that the 
  92.   combined length of all strings does not exceed the max length
  93.   allowed for strings.
  94.  
  95.     (********************************************)
  96.     (*    UCSD PASCAL                *)
  97.     (*                        *)
  98.     (* New_string := CONCAT(arg1,arg2,...argn); *)
  99.     (*                        *)
  100.     (********************************************)
  101.  
  102.     (************************************************)
  103.  
  104.  
  105.  
  106. PROCEDURE REPLACE(Source, Destination, INDEX);
  107.  
  108.     REPLACE(Main,Next,N);
  109.     PRINT(Next);
  110.  
  111.     Replaces the characters in Destination with those
  112.   from the substring Source starting at position INDEX.
  113.  
  114.  
  115.     (*****************************************)
  116.     (*    UCSD PASCAL             *)
  117.     (*                     *)
  118.     (* INSERT(SOURCE,DESTINATION,INDEX);     *)
  119.     (*                     *)
  120.     (*****************************************)
  121.  
  122.     (************************************************)
  123.  
  124.  
  125.  
  126. PROCEDURE GetLine(STRING,count);
  127.  
  128.     Returns a string and the strings length input
  129.  from the console. The string must be a valid ASCII
  130.  character. Returns a length of zero if an error is
  131.  made.
  132.  
  133.   For example:
  134.  
  135.     GetLine(BUFFER,12);
  136.  
  137.     Gets characters from the console into the String 'BUFFER'
  138.   but up to a max of 12 characters.
  139.  
  140.     (***********************************************)
  141.  
  142.