home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / basic / mxadstp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-11-09  |  1.6 KB  |  45 lines

  1. { **********************ADDSTRING ***********************
  2.   This program is in file MXADSTP.PAS  }
  3.  
  4. { Module MXADSTP--takes address and lengths of two BASIC
  5.   strings, concatenates, and creates a BASIC string descriptor. }
  6.  
  7. MODULE MAXADSTP;
  8. { Declare type ADSCHAR for all pointer types. For ease of programming,
  9.   all address variables in this module are considered pointers to
  10.   characters, and all strings and string descriptors are considered
  11.   arrays of characters. Also, declare the BASIC string descriptor
  12.   type as a simple array of four characters. }
  13.  
  14. TYPE
  15.     ADSCHAR = ADS OF CHAR;
  16.     ADRCHAR = ADR OF CHAR;
  17.     STRDESC = ARRAY[0..3] OF CHAR;
  18. VAR
  19.     MYDESC : STRDESC;
  20. { Interface to procedure BASIC routine StringAssign. If source
  21.   string is a fixed-length string, S points to string data and SL
  22.   gives length. If source string is a BASIC variable-length string,
  23.   S points to a BASIC string descriptor and SL is 0. Similarly for
  24.   destination string, D and DL. }
  25. PROCEDURE STRINGASSIGN (S:ADSCHAR; SL:INTEGER;
  26.             D:ADSCHAR; DL:INTEGER ); EXTERN;
  27.  
  28. FUNCTION ADDSTRING (S1:ADSCHAR; S1LEN:INTEGER;
  29.             S2:ADSCHAR; S2LEN:INTEGER) : ADRCHAR;
  30.  
  31.     VAR
  32.     BIGSTR : ARRAY[0..99] OF CHAR;
  33. { Execute function by copying S1 to the array BIGSTR, appending S2
  34.   to the end, and then copying combined data to the string descriptor. }
  35.  
  36.     BEGIN
  37.     STRINGASSIGN (S1, 0, ADS BIGSTR[0], S1LEN);
  38.     STRINGASSIGN (S2, 0, ADS BIGSTR[S1LEN], S2LEN);
  39.     STRINGASSIGN (ADS BIGSTR[0], S1LEN+S2LEN, ADS MYDESC[0], 0);
  40.     ADDSTRING := ADR MYDESC;
  41.     END;  { End Addstring function,}
  42. END.  {End module.}
  43.  
  44.  
  45.