Mick Arundell wrote:
>> Date: Tue, 01 Aug 2006 11:22:37 -0600
>> From: Stephen Posey <[EMAIL PROTECTED]>
>> Subject: Re: Telnet, Indy9, text file conversion;
>> To: Borland's Delphi Discussion List <[email protected]>
>> Message-ID: <[EMAIL PROTECTED]>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> [EMAIL PROTECTED] wrote:
>> <snipz>
>>
>>> Yes you can use your telnet component to retrieve a string.
>>> Standard pascal read routine will read comma separated
>>> fields
>> I'm not aware of how to do that with the Read() or ReadLn() routines
>> (which is what I presume you mean); at least not without reading an
>> entire line as a string and then parsing.
>>
>> Can you clarify?
>>
>> Stephen Posey
>> [EMAIL PROTECTED]
>>
> 
> Hi Stephen
> It goes like
>   OpenFile(handle)
> 
> read(File, Var1, Var2, Var3...);
> fairly sure it goes like that but out of practice.

To use Read() like that, Standard Pascal (and AFAIK Delphi) expects data 
values separated by white space (Space characters, and maybe Tab 
characters, haven't tried that).

Commas are interpreted as extraneous character data that prevents 
reading the values as-is.

So, expanding your example a little, some code like:

var
   Var1, Var2, Var3: Integer;
   F: TextFile; // "File" is a reserved word in Pascal
begin
   AssignFile(File, 'test.txt');
   Reset(File);
   ReadLn(File, Var1, Var2, Var3);

will work with lines like:

10 20 30
100 1000 10000

but will choke on:

10,20,30
100, 1000, 10000

Now, many dialects of BASIC include a facility to read comma delimited 
input using the INPUT command, which may be what you're recalling.

> For me I'd readln then parse myself - more control and more control I could
> get like BillG :)
> 
> Not sure if you can cast a memorystream as a filestream
> be nice if you could

TMemoryStream has LoadFromFile/SaveToFile methods which achieves a lot 
of the same thing.

Stephen Posey
[EMAIL PROTECTED]

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to