home *** CD-ROM | disk | FTP | other *** search
-
-
-
- # include "strings.h"
-
- procedure writeS{var f: Text; s: String)};
- {
- * Write the dynamic string s to file f
- *
- * precondition:
- * f open for writing
- }
- var temp: stringtail;
- i, Currentlength: Nat1; ExtraChunks: Nat0;
- begin
- if s = nil then { -- Do nothing if string = '' }
- else begin
- with s^ do begin
- ExtraChunks := (LEN-1) div slength;
- if LEN > slength then
- CurrentLength := slength
- else
- CurrentLength := LEN;
- write(f, HEAD:CurrentLength);
- temp := TAIL;
- { -- Output any tail chunks }
- for i := 1 to ExtraChunks do with temp^ do
- if i <> ExtraChunks then begin
- write(f, MORE);
- temp := REST
- end else
- if LEN mod slength <> 0 then
- write(f, MORE:(LEN mod slength))
- else
- write(f, MORE)
- end;
- { -- may have been asked to output a constant string }
- if s^.REFS = 0 then disposeS(s)
- end
- end{ -- writeS};
-
-
-