home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL5.ZIP / STRUTIL.INC < prev    next >
Encoding:
Text File  |  1987-04-16  |  831 b   |  34 lines

  1.  
  2. (*
  3.  * these macros define general utility functions that can be used on
  4.  * all kinds of variables
  5.  *
  6.  *)
  7.  
  8. #define EOS #0
  9.    {-- end of string character}
  10.  
  11. #define LEN ord(%1[0])
  12.    {-- length of a string:  ...(str)}
  13.  
  14. #define TRUNC %1[0] := EOS
  15.    {-- truncate a string (make 0 length):  ...(str)}
  16.  
  17. #define CONCAT_CHAR     \
  18.    begin                \
  19.       INC(%1[0]);       \
  20.       %1[LEN(%1)] := %2 \
  21.    end
  22.    {-- concatenate a char to a buffer:  ...(buffer,char)}
  23.  
  24. #define CONCAT_STR                         \
  25.    begin                                   \
  26.       move(%2[1], %1[LEN(%1)+1], LEN(%2)); \
  27.       %1[0] := chr(LEN(%1)+LEN(%2))        \
  28.    end
  29.    {-- concatenate a string to a buffer:  ...(buffer,str)}
  30.  
  31. #define COPY_STR move(%2[0],%1[0],LEN(%2)+1)
  32.    {-- copy strings:  ...(to,from)}
  33.  
  34.