TIP: Click on subject to list as thread! ANSI
echo: pascal
to: ALL
from: `mark lewis`
date: 1999-03-03 00:00:00
subject: streams and collections..

ML>> i've not done a lot of stuff with objects, streams or collections... i
ML>> have something that i'm working on that i think this will come in just
ML>> perfect for...

 JB> Are input and output streams?

i think you left a word out 

yes, TWorkStream is an I/O stream... as is the EMSstream and the XMSstream...

ie:

PROGRAM XMSCopy;

USES Objects, Streams;  {The Object unit is need to access TStream}

VAR
  InFile, OutFile : PStream;       {Pointer to InPut/OutPut Files}
  XMSStream       : PStream;       {Pointer to XMS Memory Block}
  InPos           : LongInt;       {Where are we in the Stream}

BEGIN
  Writeln;
  Writeln('                  XMSCopy v1.00');
  Writeln;
  Writeln('{ Mangled together from code in the FIDO PASCAL Echo }');
  Writeln('{ Assembled by Mark Lewis                            }');
  Writeln('{ Some ideas and code taken from examples by         }');
  Writeln('{ DJ Murdoch and Todd Holmes                         }');
  Writeln('{ Released in the Public Domain                      }');
  Writeln;
  If ParamCount < 2 Then
    Begin
      Writeln('Usage: XMSCopy  ');
      Halt(1);
    End;
  Infile := New(PBufStream,init(paramstr(1),stOpenRead,8192));
{  Infile := New(PDosStream,init(paramstr(1),stOpenRead));}
  If (InFile^.Status  stOK) Then
    Begin
      Writeln(#7,'Error! Source File Not Found!');
      InFile^.Reset;
      Dispose (InFile, Done);
      Halt(2);
    End;
  Outfile := New(PBufStream,init(paramstr(2),stCreate,8192));
{  Outfile := New(PDosStream,init(paramstr(2),stCreate));}
  If (OutFile^.Status  stOK) Then
    Begin
      Writeln(#7,'Error! Destination File Creation Error!');
      OutFile^.Reset;
      Dispose (OutFile, Done);
      Halt(3);
    End;
  XMSStream := New(PXMSStream, Init (1, InFile^.GetSize));
  If (XMSStream^.Status  stOK) Then
    Begin
      Writeln(#7,'Error! XMS Allocation Error!');
      Writeln('At Least One Page of XMS Required :(');
      XMSStream^.Reset;
      Dispose (XMSStream, Done);
      Halt(4);
    End;
  Writeln('InPut File Size :     ',InFile^.Getsize:10,' Bytes');
  InPos := XMSStream^.GetSize;
  Repeat
    Write('Filling XMS Buffer... ');
    XMSStream^.CopyFrom (InFile^, InFile^.GetSize-InPos);
    if (XMSStream^.Status  stOK) then
      XMSStream^.Reset;
    InPos := InPos + XMSStream^.GetSize;
    Write(XMSStream^.GetSize:10,' Bytes   ');
    XMSStream^.Seek(0);
    Write('Writing DOS File... ');
    OutFile^.CopyFrom (XMSStream^, XMSStream^.GetSize);
    Writeln(OutFile^.Getsize:10,' Bytes');
    If (InFile^.Status  stOK) Then
      InFile^.Reset;
    If (OutFile^.GetSize < InFile^.GetSize) Then
      Begin
        XMSStream^.Seek(0);
        XMSStream^.Truncate;
        InFile^.Seek(InPos);
      End;
  Until (OutFile^.GetSize = InFile^.GetSize);
  Writeln('Done!');
  DISPOSE (InFile, Done);
  DISPOSE (OutFile, Done);
  DISPOSE (XMSStream, Done);
END.

you can see where i have commented out my original DOSStream stuff so as to be
able to use the buffered stream... i can post what i have (i think) or i can
make it available over the internet if needed for someone to take a look at...

)\/(ark

---
 # Origin:  (1:3634/12)
/======================================================================
| Orange County Usenet  Fidonet gateway                              
|                                                                      
| User email address:   mark.lewis.noemail@webworldinc.com                                             
| User FTN Email gateway: nospam.mark lewis@.f12.n3634.z1.fidonet.org
| User FidoNet address: 1:3634/12                                             
| Report abuse of this service to joejared@webworldinc.com

SOURCE: alt.fidonet via archive.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.