![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#2
|
|||
|
|||
|
TStream.WriteBuffer/ReadBuffer
Esta respuesta la da Peter Below de los TeamB a un usuario....no se si está permitido poner este tipo de mensajes
pero como soy nuevo lo pongo y si alguien tiene algo que decir que lo diga, que lo borre y todos contentos y felices In article <[email protected]>, Bob McKinnon wrote: > I would like to write out an array of long strings along with other data to > a file. I tried to create a file records like I normally do but that did > not work since I was using a string. I wonder if streams is the way to go? > To make it simple, if I have a data object that contains two integers and > an array of strings it easy to stream that out to file? Sample code would > be great. > > Test = class (Tobject) > x, x1 : Integer; > StList : array [1..100] of string; > End; Since strings are variable-length data you need to write the length of a string in addition to the characters to the stream, otherwise you cannot read them back conveniently. Lets add two methods to your Test class: Since ReadBuffer and WriteBuffer use untyped parameters handing them an Ansistring (which is a pointer type) is a bit unintuitive: you have to pass the first character of the string to get the correct address across. -- Peter Below (TeamB) Última edición por vtdeleon fecha: 03-01-2006 a las 20:25:00. |
|
|
|