Prueba Stream
Program TestStream; uses classes; Var Stream : TMemoryStream; S,T : String; begin S:='ABCDEFGHIJKLMNOPQRSTUVWXYZ'; T:=S; Writeln ('Creating stream.'); Stream:=TMemoryStream.Create; Writeln ('Initial Size : ',Stream.Size); Writeln ('Initial Position : ',Stream.Position); Writeln ('Setting new size to 100'); Stream.Size:=100; Writeln ('New Size : ',Stream.Size); Writeln ('new Position : ',Stream.Position); Stream.WriteByte (1); Stream.WriteWord (2); Stream.WriteDWord (3); Stream.WriteBuffer (S[1],Length(S)); Writeln ('Size after write : ',Stream.Size); Writeln ('Position after write : ',Stream.Position); Writeln ('Truncating size'); Stream.Size:=Stream.Position; Writeln ('Stream Size is : ',Stream.Size); Writeln ('Stream Position : ',Stream.Position); Writeln ('Seek to position 0 : ', Stream.Seek(0,soFromBeginning)); Writeln ('new Position : ',Stream.Position); If Stream.ReadByte<>1 then Writeln ('First byte not 1'); If Stream.ReadWord<>2 then Writeln ('First word not 2'); If Stream.ReadDWord<>3 then Writeln ('First Word not 3'); If Stream.Read(T[1],Length(S))<>Length(S) then Writeln ('Couldn''t read string.'); Stream.WriteByte (1); Stream.WriteWord (2); Stream.WriteDWord (3); Stream.WriteBuffer (S[1],Length(S)); Writeln ('Stream Size is : ',Stream.Size); Stream.SaveToFile('Test2.dat'); Stream.Free; end. $Log: mstream.pp,v $ Revision 1.4 2005/02/14 17:13:18 peter * truncate log }
Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por personas con únicamente conocimiento básico del lenguaje, no de programación.
Otro punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:
- Si es lenguaje C [c]Código en C[/c]
- Si es lenguaje Pascal [pascal]Aquí dentro el código de Pascal[/pascal].
De esta manera el código coloreas el código.
Otro punto importante para muchos que sienten que se les ignora: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el con lo siguiente:Me reservo el derecho de alterar, publicar o no los comentarios as´ como cambiar mis condiciones en el momento que así lo requiera.
¿estas de acuerdo? entonces adelante que ya te he quitado bastante tiempo leyendo esta basura de advertencias :)