MODULE Pickles EXPORTS Main;

IMPORT
  IO,
  Pickle2 AS Pickle,
  Rd,
  TextRefTbl,
  TextRd,
  TextWr,
  Wr;

VAR
  t: TextRefTbl.T := NEW(TextRefTbl.Default).init();
  k: TEXT;
  v: REFANY;

BEGIN
  EVAL t.put("a", NIL);
  EVAL t.put("b", NIL);
  EVAL t.put("b", NIL);

  WITH wr = TextWr.New() DO
    Pickle.Write(wr, t);
    WITH rd = TextRd.New(TextWr.ToText(wr)) DO
      t:=Pickle.Read(rd);
      Rd.Close(rd);
    END;
    Wr.Close(wr);
  END;

  WITH i = t.iterate() DO
    WHILE i.next(k, v) DO
      IO.Put(k & "\n");
    END;
  END;
END Pickles.
