home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOL_INC.ZIP / VARSTR.INC < prev    next >
Encoding:
Text File  |  1988-01-29  |  688 b   |  31 lines

  1.  
  2. (*
  3.  * varstr.inc - Library to manipulate variable-allocation strings.
  4.  *
  5.  * (C) 1987 Samuel H. Smith, 18-Oct-87 (rev. 18-Oct-87)
  6.  *
  7.  *)
  8.  
  9. procedure releasestr( var str:  varstring);
  10.    (* release the memory used by a varstring variable.  variable MUST
  11.       be pre-allocated or the program may crash!!! *)
  12. begin
  13.    if str <> nil then
  14.    begin
  15.       freemem(str,length(str^)+1);
  16.       str := nil;
  17.    end;
  18. end;
  19.  
  20.  
  21. procedure savestr( var tostr: varstring;
  22.                    from:      longstring);
  23.    (* save a regular string in a varstring; new allocation of varstring *)
  24. begin
  25.    releasestr(tostr);
  26.    getmem(tostr, length(from)+1);
  27.    tostr^ := from;
  28. end;
  29.  
  30.  
  31.