home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / LA / LA018.ZIP / STRG55.ARC / STRG55-.PAS < prev    next >
Pascal/Delphi Source File  |  1990-01-02  |  9KB  |  218 lines

  1. { =========================================================================== }
  2. { Strg55-.pas - String Processing Routines - Interface      ver 5.5, 01-02-90 }
  3. {                                                                             }
  4. { (Partial Source Code)                                                       }
  5. { These routines process strings, characters, and all types of numbers.       }
  6. { Several combinations of operations have been provided that are extremely    }
  7. { fast for case, classification, comparison, conversions, copy, count,        }
  8. { delete, format, justification, membership, parse, replace, search, sort,    }
  9. { tabbing, ASCIIZ, many with match/ignore case and many more - 108 routines.  }
  10. {  Copyright (C) 1989-1990 James H. LeMay                                     }
  11. { =========================================================================== }
  12.  
  13. { For IEEE reals, set $N+.  For runtime selection of 80x87 and software,      }
  14. { also use $E+.  (Note that use of $E+ will link Turbo's 12k emulator lib if  }
  15. { a procedure is called.)  These directives must also be reflected in the     }
  16. { main program as well.                                                       }
  17.  
  18. {$A-,B-,D-,E+,F-,I-,L-,N+,O-,R-,S-,V-}
  19.  
  20. UNIT Strg;
  21.  
  22. INTERFACE
  23.  
  24. var
  25.   AscSrcPtr:          pointer;    { For StrAsc  }
  26.   AscDestPtr:         pointer;    { For AscStr  }
  27.   LnSrcPtr:           pointer;    { For StrLn   }
  28.   LnDestPtr:          pointer;    { For LnStr   }
  29.   CmpIndex1:          integer;    { For StrCmp  }
  30.   CmpIndex2:          integer;    { For StrCmp  }
  31.   ReplIndex,ReplToDo: byte;       { For StrRepl }
  32.   ReplOverFlow:       boolean;    { For StrRepl }
  33.  
  34.  
  35. { -- String Operations (5) -- }
  36.  
  37. procedure StrUpr  (VAR S: string);
  38. procedure StrLwr  (VAR S: string);
  39. procedure StrRev  (VAR S: string);
  40. procedure StrSort (VAR S: string);
  41. procedure StrRoll (VAR S: string; Count: integer);
  42.  
  43.  
  44. { -- String Insert/Delete (8) -- }
  45.  
  46. procedure StrIns  (VAR Dest: string; S: string; DestIndex,MaxLen: byte);
  47. procedure ChrPadC (VAR S: string; Fill: char; Field: byte);
  48. procedure ChrPadL (VAR S: string; Fill: char; Field: byte);
  49. procedure ChrPadR (VAR S: string; Fill: char; Field: byte);
  50. procedure ChrDel  (VAR S: string; Find: char);
  51. procedure ChrDelL (VAR S: string; Find: char);
  52. procedure ChrDelR (VAR S: string; Find: char);
  53. procedure StrCut  (VAR S: string; MaxLen: byte);
  54.  
  55.  
  56. { -- String Placement (7) -- }
  57.  
  58. procedure StrCat  (VAR Dest: string; S: string; MaxLen: byte);
  59. procedure StrCatX (VAR Dest: string; S: string; indeX,Count,MaxLen: byte);
  60. procedure StrCopy (VAR Dest: string; S: string; Index,Count: byte);
  61. procedure StrOvr  (VAR Dest: string; S: string; DestIndex: byte);
  62. procedure StrMove (VAR Dest: string; S: string);
  63. procedure StrPoke (VAR Dest; S: string);
  64. procedure StrPeek (VAR Dest: string; VAR Source; Count: byte);
  65.  
  66.  
  67. { -- String Pattern (3) -- }
  68.  
  69. procedure StrFill (VAR S: string; Fill: string; Count,MaxLen: byte);
  70. procedure ChrFill (VAR S: string; Fill: char;   Count: byte);
  71. procedure StrEnum (VAR S: string; First,Last: char);
  72.  
  73.  
  74. { -- String Position (12) -- }
  75.  
  76. function  StrPosL  (S,Find: string; Nth: byte):          byte;
  77. function  StrPosLI (S,Find: string; Nth: byte):          byte;
  78. function  StrPosR  (S,Find: string; Nth: byte):          byte;
  79. function  StrPosRI (S,Find: string; Nth: byte):          byte;
  80. function  StrPosX  (S,Find: string; indeX: byte):        byte;
  81. function  StrPosXI (S,Find: string; indeX: byte):        byte;
  82.  
  83. function  ChrPosL  (S: string; Find: char; Nth: byte):   byte;
  84. function  ChrPosLI (S: string; Find: char; Nth: byte):   byte;
  85. function  ChrPosR  (S: string; Find: char; Nth: byte):   byte;
  86. function  ChrPosRI (S: string; Find: char; Nth: byte):   byte;
  87. function  ChrPosX  (S: string; Find: char; indeX: byte): byte;
  88. function  ChrPosXI (S: string; Find: char; indeX: byte): byte;
  89.  
  90.  
  91. { -- String Count (4) -- }
  92.  
  93. function  StrQty   (S,Find: string):        byte;
  94. function  StrQtyI  (S,Find: string):        byte;
  95. function  ChrQty   (S: string; Find: char): byte;
  96. function  ChrQtyI  (S: string; Find: char): byte;
  97.  
  98.  
  99. { -- String Comparison (2) -- }
  100.  
  101. function  StrCmp   (S1,S2: string; Index1,Index2,MaxLen: byte): shortint;
  102. function  StrCmpI  (S1,S2: string; Index1,Index2,MaxLen: byte): shortint;
  103.  
  104.  
  105. { -- String Find and Replace Operations (4) -- }
  106.  
  107. procedure ChrRepl  (VAR S: string; Find,Repl: char; Index,Qty: byte);
  108. procedure ChrReplI (VAR S: string; Find,Repl: char; Index,Qty: byte);
  109. procedure StrRepl  (VAR S: string; Find,Repl: string; Index,Qty,MaxLen: byte);
  110. procedure StrReplI (VAR S: string; Find,Repl: string; Index,Qty,MaxLen: byte);
  111.  
  112.  
  113. { -- String Member/Non-member (3) -- }
  114.  
  115. function  StrBrk   (S,Breaks:  string; Index: byte): byte;
  116. function  StrSpn   (S,Members: string; Index: byte): byte;
  117. procedure StrMemb  (VAR Dest: string; S: string);
  118.  
  119.  
  120. { -- String Parsing routines (11) -- }
  121.  
  122. function  WrdQty   (S: string):              byte;
  123. function  WrdPosL  (S: string; Nth: byte):   byte;
  124. function  WrdPosR  (S: string; Nth: byte):   byte;
  125. function  WrdPosLX (S: string; indeX: byte): byte;
  126. function  WrdPosRX (S: string; indeX: byte): byte;
  127. procedure WrdL     (VAR Dest: string; S: string; Nth: byte);
  128. procedure WrdR     (VAR Dest: string; S: string; Nth: byte);
  129. procedure WrdLX    (VAR Dest: string; S: string; indeX: byte);
  130. procedure WrdRX    (VAR Dest: string; S: string; indeX: byte);
  131. procedure WrdToken (VAR Dest: string; S,Delims: string; VAR Index: byte);
  132. procedure WrdParse (VAR Dest: string; S,Delims: string; VAR Index: byte);
  133.  
  134.  
  135. { -- String Conversions (10) -- }
  136.  
  137. function  StrHex (Num: longint; Field: byte):    string;
  138. function  StrBin (Num: longint; Field: byte):    string;
  139. function  ValBin (S: string; VAR Code: integer): longint;
  140. function  ValHex (S: string; VAR Code: integer): longint;
  141.  
  142. procedure StrDeTab (VAR Dest: string; S: string; TabSpaces: byte);
  143. procedure StrReTab (VAR Dest: string; S: string; TabSpaces: byte);
  144.  
  145. procedure AscStr (VAR AscDest; S: string);
  146. procedure LnStr  (VAR LnDest;  S: string);
  147. procedure StrAsc (VAR Dest: string; VAR AscSrc; MaxLen: byte);
  148. procedure StrLn  (VAR Dest: string; VAR LnSrc;  MaxLen: byte);
  149.  
  150.  
  151. { -- Automatic and FASTER replacement for Pascal standard routines (2) -- }
  152.  
  153. procedure Delete (VAR S: string; Index,Count: integer);
  154. function  Copy   (    S: string; Index,Count: integer): string;
  155.  
  156.  
  157. { -- String Justification (3) -- }
  158.  
  159. function  StrJL  (S: string; Field: byte): string;
  160. function  StrJC  (S: string; Field: byte): string;
  161. function  StrJR  (S: string; Field: byte): string;
  162.  
  163.  
  164. { ** Function forms of the standard STR procedure ** }
  165. { -- String Formatting (17) -- }
  166.  
  167. function  StrL   (L: longint):                       string;
  168. function  StrLF  (L: longint; Field: integer):       string;
  169. function  StrR   (R: real):                          string;
  170. function  StrRF  (R: real; Field: integer):          string;
  171. function  StrRFD (R: real; Field,Decimals: integer): string;
  172.  
  173.  
  174. { -- IEEE reals -- }
  175.  
  176. {$ifopt N+ }
  177. function  StrS   (S: single):                            string;
  178. function  StrSF  (S: single; Field: integer):            string;
  179. function  StrSFD (S: single; Field,Decimals: integer):   string;
  180. function  StrD   (D: double):                            string;
  181. function  StrDF  (D: double; Field: integer):            string;
  182. function  StrDFD (D: double; Field,Decimals: integer):   string;
  183. function  StrE   (E: extended):                          string;
  184. function  StrEF  (E: extended; Field: integer):          string;
  185. function  StrEFD (E: extended; Field,Decimals: integer): string;
  186. function  StrC   (C: comp):                              string;
  187. function  StrCF  (C: comp; Field: integer):              string;
  188. function  StrCFD (C: comp; Field,Decimals: integer):     string;
  189. {$endif N+ }
  190.  
  191.  
  192. { -- Character classification functions. (17) -- }
  193.  
  194. function  IsAlNum  (C: char): boolean;
  195. function  IsAlpha  (C: char): boolean;
  196. function  IsASCII  (C: char): boolean;
  197. function  IsCntrl  (C: char): boolean;
  198. function  IsDigit  (C: char): boolean;
  199. function  IsDOS    (C: char): boolean;
  200. function  IsFile   (C: char): boolean;
  201. function  IsGraph  (C: char): boolean;
  202. function  IsLower  (C: char): boolean;
  203. function  IsPath   (C: char): boolean;
  204. function  IsPrint  (C: char): boolean;
  205. function  IsPunct  (C: char): boolean;
  206. function  IsReal   (C: char): boolean;
  207. function  IsSigned (C: char): boolean;
  208. function  IsSpace  (C: char): boolean;
  209. function  IsUpper  (C: char): boolean;
  210. function  IsXDigit (C: char): boolean;
  211.  
  212.  
  213. { 89 unique / 108 total routines }
  214.  
  215. IMPLEMENTATION
  216.  {...}
  217. END.
  218.